0
for (XMLProductView *pV in entries) { NSString *test = pV.appName; [allTableData addObject:test]; NSLog(@"Entries: %@", allTableData); } 

In my NSString *test I get all results. Why does the NSMutableArray 'allTableData' show up Null?

2
  • 1
    Has it definitely been alloc'd? Are you using ARC? Commented Aug 19, 2012 at 23:35
  • 1
    Most probably you never allocated it. Objective-C will happily ignore calls to a function using a null pointer, so you can run for 100 lines with the pointer null before you discover a problem. Commented Aug 19, 2012 at 23:41

1 Answer 1

5

It is hard to say because you added just a few information, but probably you are not allocating it correctly.

Try to add it before your for:

allTableData = [[NSMutableArray alloc] init]; for (XMLProductView *pV in entries) { NSString *test = pV.appName; [allTableData addObject:test]; } NSLog(@"Entries: %@", allTableData); 

--

Edit

I edited the code to try to make it clear.

Sign up to request clarification or add additional context in comments.

3 Comments

Ok when I add this, I'm getting a SIGABRT here: pV = [allTableData objectAtIndex:indexPath.row];
That is probably because indexPath.row is greater than the -length of the array.
@SaschaWieland are you putting this alloc/init inside the loop? If so don't, put it before the loop starts.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.