ArrayWithContentsOfFile can't read plist file?

Most likely, your plist is a dictionary that contains an array (Xcode 4 doesn't allow to create plists with an array as the root object). Try something like this: NSString *file = NSBundle mainBundle pathForResource:@"Data" ofType:@"plist"; NSDictionary *dict = NSDictionary dictionaryWithContentsOfFile:file; NSArray *array = dict objectForKey:@"Array"; NSLog(@"%@", array).

Thanks, but always got null! – funnyCoder Jun 2 at 4:55 Sorry, thanks it's ok :). But can you explain plz why this?

– funnyCoder Jun 2 at 4:57 @omz dude it allow to create actually allow to create array as a root – nikhil dhamsaniya Jun 2 at 4:59 I will give you a good answer :), because it's ok, but the correct answer is that you need to edit by hand te plist file. – funnyCoder Jun 2 at 5:21 @nikhil You can do it in Xcode 3 (as the screenshot in your answer shows), but not in Xcode 4, which is shown in funnyCoder's screenshot. I found it hard to believe myself.

– omz Jun 2 at 15:56.

In you application you need to change the root key name as it can not be datatype.

I changed it but no success, it seems that Xcode 4 doesn't allow array plist?! – funnyCoder Jun 2 at 5:01 Ohhh Yes it is like that – nikhil dhamsaniya Jun 2 at 5:05 So hiw to deal with that? You can give me an URL about Xcode4 Array plist support?

Thanks. – funnyCoder Jun 2 at 5:10.

I've been studied this topic and discover some differences in plist file. When I tried to create this same file above in Xcode Interface, using Add new File Property List, and after editing puting the item the same way is show in interface for the file above, the method NSArray alloc initWithContentsOfFile:path; fail, and I found the issue at structure of xml plist file. I fixed change direct in xml file as same the first example, and the method works fine.

The point is in XCode interface for plist file, you cant see these differences. The both look the same.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions