zoukankan      html  css  js  c++  java
  • 异常分析

    This is the point at which we caught the crash. "sigtramp" is the signal "trampoline." That's a fancy way of saying "I caught a signal (crash) and now I'm going to bounce to somewhere else in the code."

    MJCache

    这里崩溃了,

    @implementation MJDictionaryCache
    + (id)setObject:(id)object forKey:(id<NSCopying>)key forDictId:(const void *)dictId
    {
        // 获得字典
        NSMutableDictionary *dict = [self dictWithDictId:dictId];
        if (dict == nil) {
            dict = [NSMutableDictionary dictionary];
            objc_setAssociatedObject(self, dictId, dict, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
        }
        
        // 存储数据
        dict[key] = object;
        
        return dict;
    }
    
    + (id)objectForKey:(id<NSCopying>)key forDictId:(const void *)dictId
    {
        return [self dictWithDictId:dictId][key];
    }
    
    + (id)dictWithDictId:(const void *)dictId
    {
        return objc_getAssociatedObject(self, dictId); // here we crash 
    }
    

      

    1.分析,这个是不是线程安全的?是不是有删除了? ---- NSMutableArray 并非线程安全的

    2. 如果cache 获取的值为nil, nil[key]这样调用会crash。

    3. key 也可能是空。

  • 相关阅读:
    AutoFac学习笔记
    AutoMapper学习笔记
    ROSLYN 查看C#方法执行次数
    log4net 动态创建文件名
    WPF可切换按钮,iOS风格
    咕咕咕
    贪吃的小J
    UK Day15
    UK Day15
    UK Day15
  • 原文地址:https://www.cnblogs.com/studyNT/p/5091676.html
Copyright © 2011-2022 走看看