辞書の値を抽出したいのですが、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;
}