App crashes when adding array data to table cells
Posted
by
bassmandan
on Stack Overflow
See other posts from Stack Overflow
or by bassmandan
Published on 2012-04-07T21:54:18Z
Indexed on
2012/04/08
17:29 UTC
Read the original article
Hit count: 286
xcode
I am trying to create a table view that loads a number of tweets into the table (one per cell etc).
I am using NSXMLParser to get the information and have got as far as creating an array with the selection of tweets that I want.
However, when I try to add them to the table cells, the app crashes on the line:
cell.textLabel.text = cellValue;
An NSLog before this shows in the console that the app is getting the correct data, so I am a bit stumped as to why this isn't working.
This is the block of code that appears to be having the problem:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
// Set up the cell...
NSString *cellValue = [statuses objectAtIndex:indexPath.row];
NSLog(@"%@", cellValue);
cell.textLabel.text = cellValue;
return cell;}
If it makes a difference, I am using ARC and the latest version of XCode.
I'm still quite new to all this, so if I need to give some extra information, let me know.
Thanks in advance.
Edit:
Backtrace gives the following:
* thread #1: tid = 0x2003, 0x918a19c6 libsystem_kernel.dylib`__pthread_kill + 10, stop reason = signal SIGABRT
frame #0: 0x918a19c6 libsystem_kernel.dylib`__pthread_kill + 10
frame #1: 0x9968ff78 libsystem_c.dylib`pthread_kill + 106
frame #2: 0x99680bdd libsystem_c.dylib`abort + 167
frame #3: 0x03c93e78 libc++abi.dylib`_Unwind_DeleteException
frame #4: 0x03c9189e libc++abi.dylib`_ZL17default_terminatev + 34
frame #5: 0x0154df4b libobjc.A.dylib`_objc_terminate + 94
frame #6: 0x03c918de libc++abi.dylib`_ZL19safe_handler_callerPFvvE + 13
frame #7: 0x03c91946 libc++abi.dylib`std::terminate() + 23
frame #8: 0x03c92ab2 libc++abi.dylib`__cxa_throw + 110
frame #9: 0x0154de15 libobjc.A.dylib`objc_exception_throw + 311
frame #10: 0x013bdced CoreFoundation`-[NSObject doesNotRecognizeSelector:] + 253
frame #11: 0x01322f00 CoreFoundation`___forwarding___ + 432
frame #12: 0x01322ce2 CoreFoundation`_CF_forwarding_prep_0 + 50
frame #13: 0x0015168f UIKit`-[UILabel setText:] + 56
frame #14: 0x00003088 Twitter`-[TwitterViewController tableView:cellForRowAtIndexPath:] + 376 at TwitterViewController.m:131
frame #15: 0x000ace0f UIKit`-[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 494
frame #16: 0x000ad589 UIKit`-[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:] + 69
frame #17: 0x00098dfd UIKit`-[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 1350
frame #18: 0x000a7851 UIKit`-[UITableView layoutSubviews] + 242
frame #19: 0x00052301 UIKit`-[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 145
frame #20: 0x013bde72 CoreFoundation`-[NSObject performSelector:withObject:] + 66
frame #21: 0x01d6692d QuartzCore`-[CALayer layoutSublayers] + 266
frame #22: 0x01d70827 QuartzCore`CA::Layer::layout_if_needed(CA::Transaction*) + 231
frame #23: 0x01cf6fa7 QuartzCore`CA::Context::commit_transaction(CA::Transaction*) + 377
frame #24: 0x01cf8ea6 QuartzCore`CA::Transaction::commit() + 374
frame #25: 0x01d8430c QuartzCore`+[CATransaction flush] + 52
frame #26: 0x000124c6 UIKit`-[UIApplication _reportAppLaunchFinished] + 39
frame #27: 0x00012bd6 UIKit`-[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 1324
frame #28: 0x00021743 UIKit`-[UIApplication handleEvent:withNewEvent:] + 1027
frame #29: 0x000221f8 UIKit`-[UIApplication sendEvent:] + 68
frame #30: 0x00015aa9 UIKit`_UIApplicationHandleEvent + 8196
frame #31: 0x012a6fa9 GraphicsServices`PurpleEventCallback + 1274
frame #32: 0x013901c5 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
frame #33: 0x012f5022 CoreFoundation`__CFRunLoopDoSource1 + 146
frame #34: 0x012f390a CoreFoundation`__CFRunLoopRun + 2218
frame #35: 0x012f2db4 CoreFoundation`CFRunLoopRunSpecific + 212
frame #36: 0x012f2ccb CoreFoundation`CFRunLoopRunInMode + 123
frame #37: 0x000122a7 UIKit`-[UIApplication _run] + 576
frame #38: 0x00013a9b UIKit`UIApplicationMain + 1175
frame #39: 0x0000239d Twitter`main + 141 at main.m:16
frame #40: 0x00002305 Twitter`start + 53
Debugging console shows this:
2012-04-08 10:10:05.084 Twitter[25309:f803] (
{
text = "Have you shared the Shakedown yet? http://t.co/WHrIC9w7";
},
{
text = "For all you closet rocknrollas pencil in Sat 12th May The Rebirth of Rock n Roll Party. Haywire Saint @ The Good... http://t.co/OXHKlLIV";
},
{
text = "4 weeks today: Vocal tracks will be getting recorded at The Premises Studios";
},
{
text = "Rehearsal tonight in preparation to some big recording next month!";
},
{
text = "haywire saint 'great taste.' Tune. \n\nhttp://t.co/GKmu5Lna http://t.co/0fii55Hw";
},
{
text = "Meeting up with an old roadie for The Cure today. oh the stories...... http://t.co/UeUYccme";
},
{
text = "Satisfying day of programming today.. Haywire Saint app coming along nicely with the custom music player ready to rock 'n' roll!";
},
{
text = "Happy Friday Everyone!";
},
{
text = "We had a great time at The Premises Studios yesterday. We'll be back there before long :D x";
},
{
text = "I posted a new photo to Facebook http://t.co/73qAnCvk";
}
)
2012-04-08 10:10:05.093 Twitter[25309:f803] {
text = "Have you shared the Shakedown yet? http://t.co/WHrIC9w7";
}
2012-04-08 10:10:05.094 Twitter[25309:f803] -[__NSCFDictionary isEqualToString:]: unrecognized selector sent to instance 0x6877a50
2012-04-08 10:10:05.096 Twitter[25309:f803] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary isEqualToString:]: unrecognized selector sent to instance 0x6877a50'
*** First throw call stack:
(0x13bc052 0x154dd0a 0x13bdced 0x1322f00 0x1322ce2 0x15168f 0x3088 0xace0f 0xad589 0x98dfd 0xa7851 0x52301 0x13bde72 0x1d6692d 0x1d70827 0x1cf6fa7 0x1cf8ea6 0x1d8430c 0x124c6 0x12bd6 0x21743 0x221f8 0x15aa9 0x12a6fa9 0x13901c5 0x12f5022 0x12f390a 0x12f2db4 0x12f2ccb 0x122a7 0x13a9b 0x239d 0x2305)
terminate called throwing an exception2012-04-08 10:10:05.924 Twitter[25309:f803] -[__NSCFConstantString count]: unrecognized selector sent to instance 0x5b30
© Stack Overflow or respective owner