iOS處理

- (NSDictionary *)dictionaryByReplacingNullsWithStrings {

    

    constNSMutableDictionary *replaced = [selfmutableCopy];

    

    constid nul = [NSNullnull];

    

    constNSString *blank = @"";

    

    for(NSString *keyin self) {

        constid object = [selfobjectForKey:key];

        if(object == nul) {

            //pointer comparison is way faster than -isKindOfClass:

            //since [NSNull null] is a singleton, they'll all point to the same

            //location in memory.

            [replaced setObject:blank

                         forKey:key];

        }

    }

    

    return [replacedcopy];


}

發佈了40 篇原創文章 · 獲贊 20 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章