ios - Code working on iPhone 5, not on iPod touch 4 -


i'm testing application on different devices. app works fine on iphone 5, however, when test on ipod touch 4g, eror:

*** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '***  [__nsarrayminsertobject:atindex:]: object cannot nil' *** first throw call stack: (0x33f252a3 0x3bba397f 0x33e6f8d9 0x51e25 0x35e180c5 0x35e1814d 0x35e180c5 0x35e18077 0x35e18055 0x35e1790b 0x35e17e01 0x35d405f1 0x35d2d801 0x35d2d11b 0x37a1f5a3 0x37a1f1d3 0x33efa173 0x33efa117 0x33ef8f99 0x33e6bebd 0x33e6bd49 0x37a1e2eb 0x35d81301 0x4fc8d 0x3bfdab20) libc++abi.dylib: terminate called throwing exception 

the code that's crashing one:

/********/     nsmutablearray *tituloscampotextarray = [[nsmutablearray alloc] init];     (int = 0; < campos.count; i++) {          signupcell *cell = (signupcell*)[self.tableview cellforrowatindexpath:[nsindexpath indexpathforrow:i insection:0]];         [tituloscampotextarray addobject:cell.textfield.text];     } /********/ 

i'm using custom prototype cells (signupcell.h), on uitableview inside uiview.

can't find error, or how fix it.

edit: both devices running ios 6.1.3, , i'm using xcode 4.6.1.

uitableview's -cellforrowatindexpath: method returns nil if cell isn't visible on screen when call it.

my guess on iphone 5 table can display rows @ once, while on shorter ipod touch, last 1 or 2 cells aren't visible , -cellforrowatindexpath: returns nil, makes app crash.

you shouldn't rely on -cellforrowatindexpath request model data! view controller responsible data, not table view.

use same way access model data setting table view cells' text in -tableview:cellforrowatindexpath: data source method of view controller.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -