I am developing a Note app. I have developed a save button that when is pressed it saves the note with a custom name into NSUserDefaults.
I can fetch the contents of the notes however, I cannot figure out how to get a list of the notes saved names.
For examples if a user saved 3 notes custom named like: dogs, cats, food how can I fetch this saved named into a UITableview
?
To save the notes I use:
var noteToSave: NSString = noteResult.text;
NSUserDefaults.standardUserDefaults().setObject(noteToSave, forKey: nameSave.text)
NSUserDefaults.standardUserDefaults().synchronize()
to fetch all keys:
var defaults: NSUserDefaults = NSUserDefaults.standardUserDefaults()
var defaultAsDic: [NSObject : AnyObject] = defaults.dictionaryRepresentation()
var keyArr: [AnyObject] = defaultAsDic.allKeys()
for key: String in keyArr {
NSLog("key [%@] => Value [%@]", key, defaultAsDic.valueForKey(key))
but its not working