SIGABRT received due to this code... Why?
I am trying to implement a tab bar controller, navigation controller and tableview into an application I'm working on but I am getting a SIGABRT error each time I try to run it and I don't know why and it is rather puzzling me. Below is the code that the console is referencing to (I believe):
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
// Set up the cell...
NSString *cellValue = [listOfCoffees objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;
return cell;
}
...and below is the console:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString tableView:cellForRowAtIndexPath:]: unrecognized selector sent to instance 0x6a17c00'
*** Call stack at first throw:
(
0 CoreFoundation 0x00dca5a9 __exceptionPreprocess + 18开发者_如何学JAVA5
1 libobjc.A.dylib 0x00f1e313 objc_exception_throw + 44
2 CoreFoundation 0x00dcc0bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x00d3b966 ___forwarding___ + 966
4 CoreFoundation 0x00d3b522 _CF_forwarding_prep_0 + 50
5 UIKit 0x00091b98 -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 634
6 UIKit 0x000874cc -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:] + 75
7 UIKit 0x0009c8cc -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 1561
8 UIKit 0x0009490c -[UITableView layoutSubviews] + 242
9 QuartzCore 0x016b4a5a -[CALayer layoutSublayers] + 181
10 QuartzCore 0x016b6ddc CALayerLayoutIfNeeded + 220
11 QuartzCore 0x0165c0b4 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 310
12 QuartzCore 0x0165d294 _ZN2CA11Transaction6commitEv + 292
13 QuartzCore 0x0165d46d _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 99
14 CoreFoundation 0x00dab89b __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 27
15 CoreFoundation 0x00d406e7 __CFRunLoopDoObservers + 295
16 CoreFoundation 0x00d091d7 __CFRunLoopRun + 1575
17 CoreFoundation 0x00d08840 CFRunLoopRunSpecific + 208
18 CoreFoundation 0x00d08761 CFRunLoopRunInMode + 97
19 GraphicsServices 0x010021c4 GSEventRunModal + 217
20 GraphicsServices 0x01002289 GSEventRun + 115
21 UIKit 0x0002ac93 UIApplicationMain + 1160
22 Affogato 0x00002259 main + 121
23 Affogato 0x000021d5 start + 53
24 ??? 0x00000001 0x0 + 1
)
terminate called throwing an exception
Any help would be greatly appreciated.
I'm quite sure the actual problem is somewhere else in the code, my guess would be you are using some string variable (possibly selectedCoffee ?) in place of the tableView's delegate.
The error is in the tableview delegate/datasource. CellForRowAtIndexPath is called by the tableview to query it's UITableViewCell object. Check your delegate/datasource connection.
Set a breakpoint and look where the app crash. Then we could help more.
精彩评论