ios - NSDictionary with no data at all -


i trying save data plist file created xcode.

var dict: nsmutabledictionary = nsmutabledictionary(contentsoffile: plistpath);  dict = nsmutabledictionary(dict.setvalue(speedstring, forkey: "speed"));  if (!dict.writetofile(plistpath, atomically: true)) {     nslog("failed save data"); } 

the dictionary safely wrote file.
problem set break point after if statement, debugger showed nsdictionary has 0key/value pair, weird. in xcode, added key/value pair in it.

i added code test

if (dict.valueforkey("speed") == nil) {     nslog("key missing"); } 

the console did print out "key missing".

your second line creates new dictionary. throwing away dictionary read in first line. not appending dictionary, replacing new empty dictionary.


Comments

Popular posts from this blog

bash - How do you programmatically add a bats test? -

Unable to open serial port using Putty to bluetooth device on windows 7 64 bit -

java - Getting exception in JDBC thin driver -