My tableView wasn't loading because tableView:cellForRowAtIndexPath:
wasn't being called. The NSLog
messages that I have written inside tableView:cellForRowAtIndexPath:
did not appear in the console. I had a weak
NSArray @property called listOfItems. When I changed it to strong
, the tableView finally showed it's contents. Could someone please clarify if tableView:cellForRowAtIndexPath:
wasn't being called because the NSArray was weak. Is there a connection between the listOfItems
property and the tableView:cellForRowAtIndexPath:
method being called?
Asked
Active
Viewed 232 times
0

Nicos Karalis
- 3,724
- 4
- 33
- 62

Martin Verdejo
- 1,229
- 2
- 13
- 24
-
can you post the ``numberOfSectionsInTableView:`` method? – Nicos Karalis Jul 24 '12 at 01:58
-
I think you mean numberOfRows, and even so, that would be irrelevant. – max_ Jul 24 '12 at 02:02
-
can you post it for me? i want to know how are you doing the ``numberOfRowsInTableView`` because i have the same problem once and the error was int ``numberOfRowsInTableView`` – Nicos Karalis Jul 24 '12 at 12:00
1 Answers
3
No object had a strong reference to the array. Your view controller had a reference, but it wasn't strong. This means that you don't care if it gets removed from memory, you don't need it to stick around. In this case, since your table relied on the data in the array, you don't want it to be removed from memory: you want it to stay around as long as the table stays around. To do so, you create a strong reference, which makes sure that that object isn't being removed from memory until that pointer (your property, in this case) didn't point to it anymore.

Scott Berrevoets
- 16,921
- 6
- 59
- 80