zoukankan      html  css  js  c++  java
  • NSDICTIONARY获取内容的CRASH

    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];
  • 相关阅读:
    android监听屏幕打开关闭广播无响应的情况
    2020/4/9
    2020/4/8
    2020/4/7
    conda镜像
    2020/4/3
    2020/4/2
    2020/4/1
    EYELIKE源代码解读
    bzoj3162 独钓寒江雪
  • 原文地址:https://www.cnblogs.com/tianshifu/p/4127445.html
Copyright © 2011-2022 走看看