I'm experiencing strange behavior trying to retrieve an NSString from an NSDictionary that has been saved to disk in the form of an NSData object. I can clearly save an NSString in, for example, @"key1" of the NSDictionary. I can even read that object back into an NSString and verify its accuracy using NSLog. The trouble is that I cannot seem to compare that NSString to another NSString. For example:
NSString *myOriginalString = @"frustration";
...place that as the first key in a dictionary. save the dictionary to disk, and then retrieve that dictionary later as myDictionary
NSString *myString = [myDictionary valueForKey@"key1"];
NSLog(@"myString = %@", myString); // works just fine, writes the word 'frustration' to the console
// the problem is this:
if (myString == @"frustration") {
// this doesn't work! It doesn't recognize that myString contains the word 'frustration'
}
Any ideas?
NSString *myOriginalString = @"frustration";
...place that as the first key in a dictionary. save the dictionary to disk, and then retrieve that dictionary later as myDictionary
NSString *myString = [myDictionary valueForKey@"key1"];
NSLog(@"myString = %@", myString); // works just fine, writes the word 'frustration' to the console
// the problem is this:
if (myString == @"frustration") {
// this doesn't work! It doesn't recognize that myString contains the word 'frustration'
}
Any ideas?