Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 指定标签文本仅显示格式字符串_Objective C_Uitableview_Nsmutablearray_String Formatting - Fatal编程技术网

Objective c 指定标签文本仅显示格式字符串

Objective c 指定标签文本仅显示格式字符串,objective-c,uitableview,nsmutablearray,string-formatting,Objective C,Uitableview,Nsmutablearray,String Formatting,问题是它为“Helloo NS LOOOGG 673”写了673次“NSLog部分”,但在单元格中我只能看到%d而不是673。如果我能解决这个问题,我会尝试“[[wordListV2 objectAtIndex:indexPath.row]word];而不是数字,但当我尝试将其放入单元格时它不起作用。”此外,我先尝试将其放入字符串中,然后尝试,但仍然不起作用:( 好了,伙计们,我还有一个问题 好的,现在它可以工作了,但它仍然不是我真正想要做的。我在0x10e909b中遇到异常和断点停止的问题可能

问题是它为“Helloo NS LOOOGG 673”写了673次“NSLog部分”,但在单元格中我只能看到%d而不是673。如果我能解决这个问题,我会尝试“[[wordListV2 objectAtIndex:indexPath.row]word];而不是数字,但当我尝试将其放入单元格时它不起作用。”此外,我先尝试将其放入字符串中,然后尝试,但仍然不起作用:(

好了,伙计们,我还有一个问题


好的,现在它可以工作了,但它仍然不是我真正想要做的。我在0x10e909b中遇到异常和断点停止的问题可能是什么:movl 8(%edx),%edi 我可以接收数组的计数,但无法到达数组中的对象。代码如下:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    static NSString *simpleTableIdentifier = @"MyCell2";
    int size = [wordListV2 count];
    NSLog(@"there are %d objects in the array", size);
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];



    if (cell == nil)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
    }
    // NSString *str =@"%d", [wordListV2[i] ];
    // cell.textLabel.text = str;

    cell.textLabel.text = @"%d", [wordListV2 count];//[[wordListV2 objectAtIndex:indexPath.row] word];
    NSLog(@"Helloo NS LOOOGG %d", [wordListV2 count]);
    return cell;
}
当我试图到达NSMutable数组时发生异常。此外,我不知道是否与ot有任何关系,但它也给出了这一点

“;};图层=>”, “;};图层=>” ) 2013-08-04 18:23:54.720


顺便说一句,word是我的类,word是NSSTring*类型。最后

您会看到
%d
,因为这是您分配给文本标签的字符串,字符串文字后的所有内容都被忽略(我很惊讶它甚至会编译):

您要做的是使用理解和处理格式字符串的方法创建一个新的NSString:

cell.textLabel.text = @"%d", [wordListV2 count];

NSLog()
之所以有效,是因为它可以处理格式字符串。但是,ObjC属性不处理格式字符串。

Doh,typo,应该是
stringWithFormat:
(大写字母“F”),我会解决这个问题,好的,现在它可以工作了,但这仍然是我真正想做的。可能是什么问题我在0x10e909b中遇到异常和断点停止:movl 8(%edx),%edi我可以接收数组的计数,但我无法访问数组中的对象这里是代码:Words*word=[wordListV2 objectAtIndex:0];NSLog(@“helloons LOOOGG%@”,word.word)@信天翁,听起来是另一个问题。请发布一个关于崩溃详细信息的新问题(和异常名称最有用,崩溃的汇编代码没有太大帮助)。好的,15分钟内就到了:)
cell.textLabel.text = @"%d", [wordListV2 count];
cell.textLabel.text = [NSString stringWithFormat:@"%d", [wordListV2 count]];