NSString *path = [self.dataPath stringByAppendingPathComponent:@"dummy.plist"];
NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithContentsOfFile:path];
NSString *dummyKeyValue = [dict valueForKey:@"dummyKey"]; // NSLog(@"%@",[NSString stringWithString:dummyKeyValue]); [dict release];http://www.zyxsw.net NSString *anotherString = [dummyKeyValue lowercaseString];
当使用到dummyKeyValue时 挂掉。
背景:
NSDictionary在获得里面的值后, 对Dict进行释放。此时value也全部释放了。 当有引用在使用该value时,就会野指针。
解决办法:
NSString *dummyKeyValue = [[[dict valueForKey:@"dummyKey"] retain] autorelease];