Iphone 使用NSMutableArray中的数据填充UITableView

Iphone 使用NSMutableArray中的数据填充UITableView,iphone,ios,uitableview,nsmutablearray,Iphone,Ios,Uitableview,Nsmutablearray,我想用我的NSMutableArray中的数据填充我的UITableView,但它得到了一个异常 例外情况: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryM isEqualToString:]: unrecognized selector sent to instance 0xa2ba880' My cellForRowAtIndexPa

我想用我的
NSMutableArray
中的数据填充我的
UITableView
,但它得到了一个异常

例外情况:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryM isEqualToString:]: unrecognized selector sent to instance 0xa2ba880'
My cellForRowAtIndexPath:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }

    cell.textLabel.text = [callDetailArray objectAtIndex:indexPath.row];

    [cell setAccessoryType: UITableViewCellAccessoryDisclosureIndicator];

    return cell;
}
这是阵列:

Array: (
        {
        callId = 3;
        callKeyword = CALL100;
        callName = "Call to All";
        callNumber = 5908;
    }
)

我想做的是,我的
UITaleView
中的单元格将在
callId
callKeyword
callName
callNumber
中显示
CellDetailArray
字典中的数据,这样您就可以从
NSMutableArray
中获得详细信息,如下所示:-

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
    NSMutableDictionary *d=(NSMutableDictionary*)[callDetailArray objectAtIndex:indexPath.row];
    cell.textLabel.text =[d valueForKey:@"callName"];

    [cell setAccessoryType: UITableViewCellAccessoryDisclosureIndicator];

    return cell;
}
如果要在TableCell中显示所有四个值,必须创建具有四个UIlable和Sate值的customeCell,如:-

YourLable1.text=[d valueForKey:@“callId”]

YourLable2.text=[d valueForKey:@“callKeyword”]

YourLable3.text=[d valueForKey:@“callName”]


YourLable4.text=[d valueForKey:@“callNumber”]

字典中的
CellDetailArray
数据中,这样您就可以从
NSMutableArray
获取数据,如下所示:-

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
    NSMutableDictionary *d=(NSMutableDictionary*)[callDetailArray objectAtIndex:indexPath.row];
    cell.textLabel.text =[d valueForKey:@"callName"];

    [cell setAccessoryType: UITableViewCellAccessoryDisclosureIndicator];

    return cell;
}
如果要在TableCell中显示所有四个值,必须创建具有四个UIlable和Sate值的customeCell,如:-

YourLable1.text=[d valueForKey:@“callId”]

YourLable2.text=[d valueForKey:@“callKeyword”]

YourLable3.text=[d valueForKey:@“callName”]

YourLable4.text=[d valueForKey:@“callNumber”]

您使用下面的代码

cell.textLabel.text = [[callDetailArray objectAtIndex:indexPath.row]objectForKey:@"callName" ];
您正在尝试访问字典而不是字符串。callDetailArray conatins字典数据。字典中只有字符串可用,因此您必须使用下面代码中使用的objectForKey来访问它

cell.textLabel.text = [[callDetailArray objectAtIndex:indexPath.row]objectForKey:@"callName" ];

您正在尝试访问字典而不是字符串。callDetailArray conatins字典数据。在字典中,只有字符串可用,因此您必须使用objectForKey来访问它:
cell.textLabel.text=[d valueForKey:@“callName”],我真的需要手动操作吗?您可以手动设置,如
cell.textlab.text=[d valueForKey:@“callName”]将数据保存到NSMutableDictionary pr NSDictionary中。如果您的数组像myarray==(data1、data2、data3),那么您的第一个方法工作正常。您应该调用字典上的
objectForKey:
,而不是
valueForKey:
。或者使用现代语法:
cell.textLabel.text=callDetailArray[indexPath.row][@“callName”]。关于此:
cell.textlab.text=[d valueForKey:@“callName”],我真的需要手动操作吗?您可以手动设置,如
cell.textlab.text=[d valueForKey:@“callName”]将数据保存到NSMutableDictionary pr NSDictionary中。如果您的数组像myarray==(data1、data2、data3),那么您的第一个方法工作正常。您应该调用字典上的
objectForKey:
,而不是
valueForKey:
。或者使用现代语法:
cell.textLabel.text=callDetailArray[indexPath.row][@“callName”]。使用此代码时,它就像一个符咒。我想做的是,在不同的单元格中显示
callId
callKeyword
callName
callNumber
。您必须创建尽可能多的标签。您可以使用相同的代码,但键和标签应该不同。使用此代码时,它就像一个符咒。我想做的是,在不同的单元格中显示
callId
callKeyword
callName
callNumber
。您必须创建尽可能多的标签。您可以使用相同的代码,但键和标签应该是different@NitinGohel ha为你指明了正确的方向。问题是您试图将字典放入一个属性,该属性需要字符串值。@Nitin Gohel ha为您指明了正确的方向。问题是,您试图将字典放入一个需要字符串值的属性中。