plist-NSMutableDictionary-0x0

plist-NSMutableDictionary-0x0,dictionary,plist,mutable,Dictionary,Plist,Mutable,我有一个问题: NSString *filePath = [[NSBundle mainBundle] pathForResource:@"Settings" ofType:@"bundle"]; NSString *settingPath = [[[NSString alloc] init] autorelease]; settingPath = [[NSBundle bundleWithPath:filePath] pathForResource:@"Root" ofType

我有一个问题:

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"Settings" ofType:@"bundle"];
    NSString *settingPath = [[[NSString alloc] init] autorelease];
    settingPath = [[NSBundle bundleWithPath:filePath] pathForResource:@"Root" ofType:@"plist"];
    NSMutableDictionary *plist = [[[NSMutableDictionary alloc] init] autorelease];
    plist = [NSMutableDictionary dictionaryWithContentsOfFile:settingPath];
在此plist为nil之后,地址为0x0。。。但是为什么呢?
有人能帮我吗?

下面是一些应该可以正常工作的代码:

NSString* path = [[NSBundle mainBundle] pathForResource:@"myfile" ofType:@"plist"];
NSDictionary* dictionary = [NSDictionary dictionaryWithContentsOfFile:path];
请注意,plist必须有效,否则将得到一个空值


另外,请注意,如果您只是想在另一个调用中覆盖变量的值,则不需要使用alloc/init来创建变量。

问题有点老了,但可以。几个月前我就这样做了:-)