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
Post a Comment