0
- (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;
}

The problem is it writes "NSLog part" for "Helloo NS LOOOGG 673" for 673 times but in cell I can only see %d not 673. If I can solve this problem I ll try "[[wordListV2 objectAtIndex:indexPath.row] word]; instead of the number but It doesnt work when Im trying to put it inside cell." Moreover I tried to put it inside a string first then tried but still not working :(

Ok Guys its working now I have another problem

Okey now it works but Its still not what I really want to do. What might be the problems I got an exception and breakpoint stops in 0x10e909b: movl 8(%edx), %edi I can receive the count of my Array but I cant reach the objects inside it Here is the code :

 Words * word = [wordListV2 objectAtIndex:0];
 NSLog(@"Helloo NS LOOOGG %@",word.word);
 cell.textLabel.text = word.word;

Exception happens when Im trying to reach the NSMutable Array. Moreover I dont know is there any relation with ot but it gives also this

"; }; layer = >", "; }; layer = >" ) 2013-08-04 18:23:54.720

Btw Words is my class and word is NSSTring * type. And in the end

albatross
  • 455
  • 2
  • 8
  • 27

1 Answers1

2

You see %d because that is the string you are assigning to the text label, everything after the string literal is ignored (I'm surprised it even compiles):

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

What you want to do is to create a new NSString using a method that understands and processes format strings:

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

The reason that the NSLog() works is because it can process format strings. However, ObjC properties do not handle format strings.

BergQuester
  • 6,167
  • 27
  • 39
  • Doh, typo, should be `stringWithFormat:` (capital 'F') I'll fix the answer, – BergQuester Aug 03 '13 at 17:32
  • Okey now it works but Its still what I really want to do. What might be the problems I got an exception and breakpoint stops in 0x10e909b: movl 8(%edx), %edi I can receive the count of my Array but I cant reach the objects inside it Here is the code : Words * word = [wordListV2 objectAtIndex:0]; NSLog(@"Helloo NS LOOOGG %@",word.word); – albatross Aug 04 '13 at 15:25
  • @albatross That sounds like a different question. Please post a new question with the crash details (the [stack trace](http://stackoverflow.com/questions/10501358/objective-c-getting-line-number-or-full-stack-trace-from-debugger-error) and exception name are most useful, the assembly code where it crashed is not so helpful). – BergQuester Aug 04 '13 at 19:27
  • Okey here its coming within 15 mins :) – albatross Aug 05 '13 at 06:28