Ios [\uu NSCFString count]:发送到实例的选择器无法识别

Ios [\uu NSCFString count]:发送到实例的选择器无法识别,ios,objective-c,uitableview,Ios,Objective C,Uitableview,过去几天我一直在搜索这个问题 在我的文件.h中,我将其放在界面中: NSMutableArray *newsCount; @property (nonatomic, retain) NSMutableArray *newsCount; 在我的文件.m中,我编写了这段代码 我已分配此视图将出现的方法: - (void)viewWillAppear:(BOOL)animated{ self.newsCount = [[NSMutableArray alloc] init]; } - (N

过去几天我一直在搜索这个问题

在我的文件.h中,我将其放在界面中:

NSMutableArray *newsCount;
@property (nonatomic, retain) NSMutableArray *newsCount;
在我的文件.m中,我编写了这段代码

我已分配此视图将出现的方法:

- (void)viewWillAppear:(BOOL)animated{
self.newsCount = [[NSMutableArray alloc] init];
}

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
        return [self.newsCount count];
       //    return 5;
    }

    - (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] autorelease];
    }

    // Configure the cell.
    cell.textLabel.text = [NSString stringWithFormat:@"- %@",[[newsCount objectAtIndex: indexPath.row] objectForKey:@"RELATED_CAPTION"]];
    [cell.textLabel setFont:[UIFont fontWithName:@"Helvetica" size:13]];
    cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;
    cell.textLabel.numberOfLines = 2;
    cell.textLabel.textColor = [UIColor grayColor];
    return cell;
    }

您如何设置self.newscont

您没有将数组放入
self.newscoount
,或者(更可能)您正在设置“
newscoount
”而不保留它


您是否正在使用
ARC
?如果没有,您应该是。

如何设置
self.newscont

您没有将数组放入
self.newscoount
,或者(更可能)您正在设置“
newscoount
”而不保留它


您是否正在使用
ARC
?如果没有,您应该这样做。

如果您正在设置newsCount,就像您在对@Kendall答案的评论中提到的那样:

newsCount = [[[GlobalVariable sharedInstance].itemNewsDetail objectAtIndex:i]objectForKey:@"RELATED"];
那么问题可能是因为该对象不是NSMutableArray,而是NSString(\uu NSCFString是NSString使用的私有类)

您可能希望通过在我前面提到的行之后添加此行来转储
[GlobalVariable sharedInstance].itemNewsDetail
的内容:

NSLog(@"itemNewsDetail: %@",[[GlobalVariable sharedInstance].itemNewsDetail objectAtIndex:i]);

如果您正在设置newsCount,如您在对@Kendall回答的评论中所述,请检查“相关”键中存储的内容:

newsCount = [[[GlobalVariable sharedInstance].itemNewsDetail objectAtIndex:i]objectForKey:@"RELATED"];
那么问题可能是因为该对象不是NSMutableArray,而是NSString(\uu NSCFString是NSString使用的私有类)

您可能希望通过在我前面提到的行之后添加此行来转储
[GlobalVariable sharedInstance].itemNewsDetail
的内容:

NSLog(@"itemNewsDetail: %@",[[GlobalVariable sharedInstance].itemNewsDetail objectAtIndex:i]);


并检查键
@“RELATED”
..

NSArray*newscont中存储的内容;取而代之的是NSMutableArray*newsCount;哪一行代码导致了错误?您是否可以打印您的newsCount数组在您初始化数组的位置提供代码
newsCount
问题在于numberOfRowsInSection方法I:您正在创建或初始化的数组的方式错误。实际上,编译器将您的newscount数组视为NSString.NSArray*newscount;取而代之的是NSMutableArray*newsCount;哪一行代码导致了错误?您是否可以打印您的newsCount数组在您初始化数组的位置提供代码
newsCount
问题在于numberOfRowsInSection方法I:您正在创建或初始化的数组的方式错误。实际上,编译器将newscount数组视为NSString。我已经这样设置了<代码>新闻计数=[[GlobalVariable sharedInstance].itemNewsDetail objectAtIndex:i]objectForKey:@“相关”]@Template09如果不使用ARC,请保留该变量!可能是您在这里为newsCount传递字符串值,我想检查一下就可以了。我已经在文件中保留了它。h`@property(nonatomic,retain)NSMutableArray*newsCount`但是您直接分配给ivar,而不是通过保留选择器。使用
self.newscont=…
(并且根本不要使用
@synthetic newscont
)。更好的是,打开弧。我已经这样设置了<代码>新闻计数=[[GlobalVariable sharedInstance].itemNewsDetail objectAtIndex:i]objectForKey:@“相关”]@Template09如果不使用ARC,请保留该变量!可能是您在这里为newsCount传递字符串值,我想检查一下就可以了。我已经在文件中保留了它。h`@property(nonatomic,retain)NSMutableArray*newsCount`但是您直接分配给ivar,而不是通过保留选择器。使用
self.newscont=…
(并且根本不要使用
@synthetic newscont
)。更好的是,打开ARC.yap,当我像你说的那样设置新闻计数而不使用“RELATED”键时,我的numberOfRowsInSection方法与[self.newsCount]方法运行良好。。那么我如何在cellforrowatinexpath方法中处理它以显示数据???@Template09要知道这一点,我需要查看NSLog语句的输出。你能发布它吗?记录对象的类名可能更有用,因为这似乎是问题所在,而不是对象的内容。@MarkThalman你是对的,但我认为现在这么做有点晚了:)是的,当我像你说的那样设置新闻计数而不使用@“RELATED”键时,我的numberOfRowsInSection方法运行得很好[self.newscont]方法..那么我如何在cellForRowAtIndexPath方法中处理它以显示数据???@Template09要知道这一点,我需要查看NSLog语句的输出。你能发布它吗?记录对象的类名可能更有用,因为这似乎是问题所在,而不是对象的内容。@MarkThalman你是对的,但我认为它是b现在已经很晚了:)