문제

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]);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top