Pregunta

I have these plist files that I have used without problem, converting them into arrays with either arraywithcontentsoffile or initwithcontentsoffile. All of a sudden it stopped working, when I inspect the arrays in the debugger i get this as elements.

" Printing description of [0]:(<invalid>) [0] = <error: expected ']'error: 1 errors parsing expression>"

Does anyone have a clue? strange thing is that the command has completely stopped working. I even made a new project using a new file and it still throws me this error.

This is what i do:

NSArray *name = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"example" ofType:@"plist"]];

and the plist is just a simple plist of type array and element-type string

¿Fue útil?

Solución

Just Try it...

NSURL *url = [[NSBundle mainBundle] URLForResource:@"YOURPLIST" withExtension:@"plist"];
NSArray *playDictionariesArray = [[NSArray alloc ] initWithContentsOfURL:url];

NSLog(@"Here is the Dict %@",playDictionariesArray);

or you can use following also

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"Sample.plist"];

Otros consejos

This appears to be a very old Xcode bug. Do an NSLog dump to see if the values are there. This inspector doesn't function even as late as Xcode 6.1! I'll make a radar.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top