I guess the second object you're printing is a NSArray containing one string, not a NSString object itself. Try calling this method to see the name of the object's class.
NSLog(@"%@",[possibleStringObject class]);
質問
I have an NSArray of NSStrings that I am saving to file and then reloading from file when the app is relaunched. Strangely though, the strings have parenthesis around them after they are reloaded.
I save via: writeToFile:atomically:
and I load the array via: arrayWithContentsOfFile:
The issue is that when the NSString goes in it might look like this:
I_am_the_good_old_string
but after reloading the array from file, it looks like this:
(
I_am_the_good_old_string
)
I don't understand why they now have the parenthesis around them. Any help is appreciated.
解決
I guess the second object you're printing is a NSArray containing one string, not a NSString object itself. Try calling this method to see the name of the object's class.
NSLog(@"%@",[possibleStringObject class]);
他のヒント
The parenthesis is an array object, if you print out an array, it calls [myarray description] which looks like what you described..
(obj1,
obj2,
obj3)
You're probably printing the string, then printing the array. Try printing the string after reloading the array..
NSLog(@"myString:%@", [myArray objectAtIndex:0]);