字典tips

NSUserDefault存数组或字典的可变情况:

因为NSUserDefault只能存不可变的数组或字典;
取出来的数组或字典 如果直接addObject, 再存同一个, 就会崩溃;
只能覆盖新的.

NSMutableDictionary *storedCaptureDic = UserDefaultsGet(CaptureCameraUrlDic);
NSMutableDictionary *copyDic = storedCaptureDic.mutableCopy;
                [copyDic setObject:url forKey:self.deviceSerial];
                UserDefaultsSave(copyDic, CaptureCameraUrlDic);
比较两个字典:

用isEqual方法即可.

字典遍历:
[_lastCaptureDic enumerateKeysAndObjectsUsingBlock:^(id  _Nonnull key, NSString * url, BOOL * _Nonnull stop) {
            if ([key isEqualToString:deviceSerial]) {

                *stop = YES;
            }
        }];

你可能感兴趣的:(OC,知识点)