zoukankan      html  css  js  c++  java
  • 检查字典中是否有NULL 类型,如果有的话,转换成"",因为字典中又null ,是不能存入到NSUserDefalut 里面的.

    //该方法是检查字典中是否有nil 的,有nil就转行成""

    - (NSDictionary *)checkDict:(NSDictionary *)sender

    {

        NSMutableDictionary * dict_mutable = [[NSMutableDictionary alloc] init];

        NSArray * keys = sender.allKeys;

        for (NSString * key in keys) {

            if ([[sender objectForKey:key] isKindOfClass:[NSDictionary class]]) {

                 NSDictionary * tempDict = [self checkDict:[sender objectForKey:key]];

                [dict_mutable setObject:tempDict forKey:key];

            }

            else{

                if ([[sender objectForKey:key] isKindOfClass:[[NSNull null] class]]) {

                    [dict_mutable setObject:@"" forKey:key];

                }

                else{

                    [dict_mutable setObject:[sender objectForKey:key] forKey:key];

                }

            }

        }

        return dict_mutable;

    }

  • 相关阅读:
    SVN 使用学习记录
    jQuery 获取 URL信息
    JS扩展方法
    .Net 加密 哈希
    SQL Serverf 索引
    SQL Server索引
    SQL Server索引
    insert into select 多个表
    Mysql数据库自带四个数据库的解析
    转: MySQL5.7 ERROR 1142 (42000)问题
  • 原文地址:https://www.cnblogs.com/yinyakun/p/4335020.html
Copyright © 2011-2022 走看看