user7522836
user7522836

Reputation: 1

NSMutableDictionary ,setValue:forKey: crash

By chance, this code will crash:

-(void)addCallbackOfFileType:(SendFileType)fileType
                    callback:(sendProcess)callback
                      target:(id)target{
    
    [_hashTable addObject:target];

    NSString * targetKeyStr = NSStringFromClass([target class]);
    if (callback && targetKeyStr) {
        NSString * fid = [NSString stringWithFormat:@"%d",(int)fileType+KBigFileAdded];
        NSMutableDictionary * targetMdic = [[NSMutableDictionary alloc]init];
        if ([_callbacks valueForKey:targetKeyStr]) {
            targetMdic = [_callbacks valueForKey:targetKeyStr];
        }
        [targetMdic setValue:callback forKey:fid];
        [_callbacks setValue:targetMdic forKey:targetKeyStr];
    }
    
}

It crashes on this line:

[targetMdic setValue:callback forKey:fid];

This is a screenshot of the crash:

enter image description here

How to fix this crash?

Upvotes: 0

Views: 52

Answers (0)

Related Questions