iphone - Inserting 8 or more objects into array crashes app -


simple question,

i loop thru table view cells , add objects array:

nsmutablearray *cells = [[nsmutablearray alloc] init]; (nsinteger j = 0; j < [self.ammotable numberofsections]; ++j) // loop thru sections {     (nsinteger = 0; < [self.ammotable numberofrowsinsection:j]; ++i)//in each section loop thru cells     {         [cells addobject:[self.ammotable cellforrowatindexpath:[nsindexpath indexpathforrow:i insection:j]]];     }        } 

this works perfect, long table view has 7 or less cells, if add 8 or more, app crashes log console:

'nsinvalidargumentexception', reason: '*** -[__nsarraym insertobject:atindex:]: object cannot nil'

any appreciated!

the cellforrowatindexpath: method of uitableview returns nil if index path refers cell not visible, therefore

[cells addobject:[self.ammotable cellforrowatindexpath:[nsindexpath indexpathforrow:i insection:j]]]; 

crashes in case.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -