我想提取字典的值却返回null。为什么?
我的代码:
- (void)viewDidLoad
{
//....
self.mutableArray =[[NSMutableArray alloc]init];
self.mutableDictionary =[NSMutableDictionary dictionaryWithObjectsAndKeys:@"Carrello", @"Name List", @"18", @"Number", nil];
[mutableArray addObject:self.mutableDictionary];
//....
}
后
- (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"Login";
self.cellCustom = (CellCustomTableList*)[aTableView
dequeueReusableCellWithIdentifier:CellIdentifier];
if(self.cellCustom == nil){
self.cellCustom = [[CellCustomTableList alloc]
initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] ;
}
NSDictionary * dictionary = [self.mutableArray objectAtIndex:indexPath.row];
NSLog(@"the dictionary %@", dictionary);
/*the dictionary {
"Name List" = Carrello;
"Number" = 18;
}*/
NSLog(@"%@", [dictionary objectForKey:@"Name List"]);
// (null)
NSLog(@"%@", [dictionary objectForKey:@"Number"]);
// (null)
NSLog(@"%@", [dictionary allKeys]);
/*(
"Name List",
"Number"
)
*/
int i =[self.mutableArray indexOfObject:dictionary];
NSLog(@"%d", i);
//0
return self.cellCustom;
}