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];

相关文章:

  • 2021-11-21
  • 2022-02-09
  • 2021-09-17
  • 2021-06-17
  • 2021-11-28
  • 2022-01-02
  • 2021-11-12
  • 2021-09-20
猜你喜欢
  • 2022-12-23
  • 2021-07-11
  • 2022-12-23
  • 2021-07-24
  • 2022-01-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案