Class Object始终为null

时间:2013-12-30 10:24:44

标签: ios iphone objective-c ios7

这是我的应用程序通过来自服务器的联系人完成下载的方法。在for循环中我使用AIContactParsarModal类并使用字典我正在设置对象,但每次对象值为空时

感谢您的帮助,任何帮助都会很明显。这是我的代码。

- (void)donewithContact {

    self.allPersonDetailsDict = [[NSMutableDictionary alloc]initWithCapacity:1];
    NSMutableArray *allKeysArray = [[NSMutableArray alloc] init];

    NSString *prefix;

    NSString *searchContactString = [[NSUserDefaults standardUserDefaults] objectForKey:@"AdvanceSearch"];
    if ([searchContactString isEqualToString:@"SpecialSearch"]) {
        [self.allPersonDetailsDict removeAllObjects];
    }
    if (getContactArray.count == 0 ){
        [noContactLabel setHidden:NO];
    } else {
        for (AIContactParsarModal *contact in getContactArray) {
            NSLog(@"contact LAST NAMES ARE %@",contact.lastName);
            prefix = [[contact.lastName substringWithRange:NSMakeRange(0, 1)] uppercaseString];

            if ([allKeysArray containsObject:prefix]) {
                NSMutableArray *conatctsWithPrefix = [_allPersonDetailsDict objectForKey:prefix];
                [conatctsWithPrefix addObject:contact];
            } else {
                [allKeysArray addObject:prefix];
                NSMutableArray *conatctsWithPrefix = [[NSMutableArray alloc] initWithObjects:contact,nil];
                [self.allPersonDetailsDict setObject:conatctsWithPrefix forKey:prefix];
                NSLog(@"conatctsWithPrefix %@",conatctsWithPrefix);
            }
        }
    [noContactLabel setHidden:YES];
    }
    NSLog(@"All Names First characters are:%@", allKeysArray);

    [self.contactTableView reloadData];
    [HUD hide:YES];
}

1 个答案:

答案 0 :(得分:1)

可能是你在conatctsWithPrefix

中获取null的联系人中的空值

存储在联系中的第一个打印值。