开发者

Can't read from plist

I have a plist with an array at top level and then a number of items within it.

When I try the following

NSString *path = [[NSBundle mainBundle] bundlePath];
NSString *finalPath = [path stringByAppendingPathComponent:@"Spots.plist"];

spotsArray = [[开发者_如何转开发NSMutableArray arrayWithContentsOfFile:finalPath] retain];

the array spotsArray is empty.

I have tried a number of things and have used plists successfully before. I dont know what the issue is now.

What could be causing the issue, my plist looks like this

Can't read from plist


It's not an array at the top level it's a dictionary with a single item called 'New Item'.

Try NSMutableArray *mutableArray = [[[NSDictionary dictionaryWithContentsOfFile:finalPath] objectForKey:@"New Item"] mutableCopy] autorelease]


This should mean that your .plist file does not exist or not readable. Try to create the file with writeToFile at the same path to verify it works. (It can also help you to verify the directory)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜