开发者

Failing to read array data from a plist - (null) ejected

I am currently trying to get data out of a plist.

It basically looks like that:

plist called 'woerter'  
  -> Root key of type Dictionary  
    -> woerter key of type Array  
      -> various Items of type String with string Values

When I now try to read a random string from it, I only get a (null) expression

NSString * path = [[NSBundle mainBundle] bundlePath];
NSString * finalPath = [path stringByAppendingPathComponent:@"woerter.plist"];
NSDictionary * plistData = [[NSDictionary dictionaryWithContentsOfFile:finalPath] retain];
NSArray * array = [plistData valu开发者_运维问答eForKey:@"woerter"];
NSString * string = [array objectAtIndex:arc4random() %110];
NSLog(@"stringtest %@", string);

But all i get is

2010-02-28 23:01:58.911 TypeFast[5606:a0f] stringtest (null)

It is not a problem with arcrandom either since objectAtIndex:2 returns the same.

Where is the problem?

Thank you (:


You forgot to alloc the NSDictionary and the NSArray, so the array and dictionary can not save the values.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜