Getting SIGABRT error - ios

Am getting a SIGABRT error in main.m:
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char * argv[])
{
#autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); // SIGABRT error
}
}
Am getting this in the console, but can't understand it:
2013-10-24 15:21:30.278 Blog_Reader[45888:a0b] -[__NSDictionaryI length]: unrecognized selector sent to instance 0xb779360
2013-10-24 15:21:30.293 Blog_Reader[45888:a0b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryI length]: unrecognized selector sent to instance 0xb779360'
*** First throw call stack:
(
0 CoreFoundation 0x017345e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x014b78b6 objc_exception_throw + 44
2 CoreFoundation 0x017d1903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x0172490b ___forwarding___ + 1019
4 CoreFoundation 0x017244ee _CF_forwarding_prep_0 + 14
5 Foundation 0x010fcb2d -[NSConcreteMutableAttributedString replaceCharactersInRange:withString:] + 39
6 Foundation 0x010fd79a -[NSConcreteMutableAttributedString initWithString:attributes:] + 293
7 UIKit 0x003d7116 -[UILabel _setText:] + 97
8 UIKit 0x003d72d4 -[UILabel setText:] + 40
9 Blog_Reader 0x00002c3d -[TableViewController tableView:cellForRowAtIndexPath:] + 301
10 UIKit 0x00318d2f -[UITableView _createPreparedCellForGlobalRow:withIndexPath:] + 412
11 UIKit 0x00318e03 -[UITableView _createPreparedCellForGlobalRow:] + 69
12 UIKit 0x002fd124 -[UITableView _updateVisibleCellsNow:] + 2378
13 UIKit 0x003105a5 -[UITableView layoutSubviews] + 213
14 UIKit 0x00294dd7 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
15 libobjc.A.dylib 0x014c981f -[NSObject performSelector:withObject:] + 70
16 QuartzCore 0x03aee72a -[CALayer layoutSublayers] + 148
17 QuartzCore 0x03ae2514 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
18 QuartzCore 0x03aee675 -[CALayer layoutIfNeeded] + 160
19 UIKit 0x0034fca3 -[UIViewController window:setupWithInterfaceOrientation:] + 304
20 UIKit 0x0026ed27 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 5212
21 UIKit 0x0026d8c6 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 82
22 UIKit 0x0026d798 -[UIWindow _setRotatableViewOrientation:updateStatusBar:duration:force:] + 117
23 UIKit 0x0026d820 -[UIWindow _setRotatableViewOrientation:duration:force:] + 67
24 UIKit 0x0026c8ba __57-[UIWindow _updateToInterfaceOrientation:duration:force:]_block_invoke + 120
25 UIKit 0x0026c81c -[UIWindow _updateToInterfaceOrientation:duration:force:] + 400
26 UIKit 0x0026d573 -[UIWindow setAutorotates:forceUpdateInterfaceOrientation:] + 870
27 UIKit 0x00270b66 -[UIWindow setDelegate:] + 449
28 UIKit 0x00341dc7 -[UIViewController _tryBecomeRootViewControllerInWindow:] + 180
29 UIKit 0x002667cc -[UIWindow addRootViewControllerViewIfPossible] + 609
30 UIKit 0x00266947 -[UIWindow _setHidden:forced:] + 312
31 UIKit 0x00266bdd -[UIWindow _orderFrontWithoutMakingKey] + 49
32 UIKit 0x0027144a -[UIWindow makeKeyAndVisible] + 65
33 Blog_Reader 0x000023bb -[AppDelegate application:didFinishLaunchingWithOptions:] + 267
34 UIKit 0x00223f65 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 309
35 UIKit 0x002247a5 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1536
36 UIKit 0x00228fb8 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
37 UIKit 0x0023d42c -[UIApplication handleEvent:withNewEvent:] + 3447
38 UIKit 0x0023d999 -[UIApplication sendEvent:] + 85
39 UIKit 0x0022ac35 _UIApplicationHandleEvent + 736
40 GraphicsServices 0x036872eb _PurpleEventCallback + 776
41 GraphicsServices 0x03686df6 PurpleEventCallback + 46
42 CoreFoundation 0x016afdd5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
43 CoreFoundation 0x016afb0b __CFRunLoopDoSource1 + 523
44 CoreFoundation 0x016da7ec __CFRunLoopRun + 2156
45 CoreFoundation 0x016d9b33 CFRunLoopRunSpecific + 467
46 CoreFoundation 0x016d994b CFRunLoopRunInMode + 123
47 UIKit 0x002286ed -[UIApplication _run] + 840
48 UIKit 0x0022a94b UIApplicationMain + 1225
49 Blog_Reader 0x00002e2d main + 141
50 libdyld.dylib 0x01d70725 start + 0
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
This is the TableViewController.m file:
#implementation TableViewController
- (void)viewDidLoad
{
[super viewDidLoad];
NSDictionary *blogPost1 = [NSDictionary dictionaryWithObjectsAndKeys:#"The Missing Widget in Android", #"title", #"Ben Jakuben", #"author", nil];
NSDictionary *blogPost2 = [NSDictionary dictionaryWithObjectsAndKeys:#"Getting Started with iOS Development", #"title", #"Amit Bijlani", #"author", nil];
NSDictionary *blogPost3 = [NSDictionary dictionaryWithObjectsAndKeys:#"An Interview with Shay Howe", #"title", #"Joe Villanueva", #"author", nil];
self.blogPosts = [NSArray arrayWithObjects:blogPost1, blogPost2, blogPost3, nil];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
// Configure the cell...
cell.textLabel.text = [self.blogPosts objectAtIndex:indexPath.row];
return cell;
}
#end

You are storing NSDictionary instances in self.blogPosts, but then in
cell.textLabel.text = [self.blogPosts objectAtIndex:indexPath.row];
you are assigning one of them to text, which expects a NSString. The compiler is not catching it since objectAtIndex: returns an object of type id, which can potentially be anything.
A possible fix (but it really depends on what you need) could be
cell.textLabel.text = self.blogPosts[indexPath.row][#"title"];

Related

Why UITableView is not displaying on UIViewController?

I am trying to set up a UITableView inside of a UIViewController. I am using storyboard. but when running it on the simulator, the tableview does not display. Here is the simple view in Xcode:
#implementation ForthViewController{
NSArray *menuItems;
}
- (void)viewDidLoad {
[super viewDidLoad];
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
NSArray *o = [prefs mutableArrayValueForKey:#"option"];
NSLog(#"%#",o);
menuItems =[NSArray arrayWithArray:o];
[self viewrequest];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return [menuItems count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *simpleTableIdentifier = #"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
cell.textLabel.text = [menuItems objectAtIndex:indexPath.row];
return cell;
}
I am getting following error:
2016-11-29 11:57:44.987 Wellness_24x7[1400:46606] -[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0x7a67d160
2016-11-29 11:57:45.010 Wellness_24x7[1400:46606] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0x7a67d160'
*** First throw call stack:
(
0 CoreFoundation 0x00b4da14 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x0060ee02 objc_exception_throw + 50
2 CoreFoundation 0x00b56d63 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x00a946bd ___forwarding___ + 1037
4 CoreFoundation 0x00a9428e _CF_forwarding_prep_0 + 14
5 UIKit 0x01884c1c -[UITableViewLabel setText:] + 120
6 Wellness_24x7 0x000f16c4 -[ForthViewController tableView:cellForRowAtIndexPath:] + 372
7 UIKit 0x014df398 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 822
8 UIKit 0x014df4e1 -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 90
9 UIKit 0x014af948 -[UITableView _updateVisibleCellsNow:isRecursive:] + 3347
10 UIKit 0x014ce0d6 __29-[UITableView layoutSubviews]_block_invoke + 52
11 UIKit 0x014e919e -[UITableView _performWithCachedTraitCollection:] + 88
12 UIKit 0x014cdfab -[UITableView layoutSubviews] + 214
13 UIKit 0x01424008 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 810
14 libobjc.A.dylib 0x00623059 -[NSObject performSelector:withObject:] + 70
15 QuartzCore 0x0569280a -[CALayer layoutSublayers] + 144
16 QuartzCore 0x056864ee _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 388
17 QuartzCore 0x05694d2a -[CALayer(CALayerPrivate) layoutBelowIfNeeded] + 44
18 UIKit 0x014117c0 -[UIView(Hierarchy) layoutBelowIfNeeded] + 1258
19 UIKit 0x014112c2 -[UIView(Hierarchy) layoutIfNeeded] + 82
20 UIKit 0x01585420 -[UITabBarController _layoutViewController:] + 845
21 UIKit 0x0158557a -[UITabBarController _wrapperViewForViewController:] + 262
22 UIKit 0x01591ba6 -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 787
23 UIKit 0x01590a0e -[UITabBarController transitionFromViewController:toViewController:] + 76
24 UIKit 0x0158c0dd -[UITabBarController _setSelectedViewController:] + 453
25 UIKit 0x0158bee4 -[UITabBarController setSelectedViewController:] + 252
26 UIKit 0x01590839 -[UITabBarController _tabBarItemClicked:] + 587
27 libobjc.A.dylib 0x006230b5 -[NSObject performSelector:withObject:withObject:] + 84
28 UIKit 0x01359b79 -[UIApplication sendAction:to:from:forEvent:] + 118
29 UIKit 0x01359af8 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 64
30 UIKit 0x017a70fb -[UITabBar _sendAction:withEvent:] + 525
31 libobjc.A.dylib 0x006230b5 -[NSObject performSelector:withObject:withObject:] + 84
32 UIKit 0x01359b79 -[UIApplication sendAction:to:from:forEvent:] + 118
33 UIKit 0x01359af8 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 64
34 UIKit 0x014f98f8 -[UIControl sendAction:to:forEvent:] + 79
35 UIKit 0x014f9c78 -[UIControl _sendActionsForEvents:withEvent:] + 408
36 UIKit 0x014f9938 -[UIControl sendActionsForControlEvents:] + 48
37 UIKit 0x017ace41 -[UITabBar(Static) _buttonUp:] + 123
38 libobjc.A.dylib 0x006230b5 -[NSObject performSelector:withObject:withObject:] + 84
39 UIKit 0x01359b79 -[UIApplication sendAction:to:from:forEvent:] + 118
40 UIKit 0x01359af8 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 64
41 UIKit 0x014f98f8 -[UIControl sendAction:to:forEvent:] + 79
42 UIKit 0x014f9c78 -[UIControl _sendActionsForEvents:withEvent:] + 408
43 UIKit 0x014f8c7e -[UIControl touchesEnded:withEvent:] + 714
44 UIKit 0x013d6182 -[UIWindow _sendTouchesForEvent:] + 1095
45 UIKit 0x013d7220 -[UIWindow sendEvent:] + 1159
46 UIKit 0x0137bf93 -[UIApplication sendEvent:] + 266
47 UIKit 0x01351668 _UIApplicationHandleEventQueue + 7802
48 CoreFoundation 0x00a676ff __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
49 CoreFoundation 0x00a5d38b __CFRunLoopDoSources0 + 523
50 CoreFoundation 0x00a5c7a8 __CFRunLoopRun + 1032
51 CoreFoundation 0x00a5c0e6 CFRunLoopRunSpecific + 470
52 CoreFoundation 0x00a5befb CFRunLoopRunInMode + 123
53 GraphicsServices 0x05133664 GSEventRunModal + 192
54 GraphicsServices 0x051334a1 GSEventRun + 104
55 UIKit 0x01357bfa UIApplicationMain + 160
56 Wellness_24x7 0x000cba6a main + 138
57 libdyld.dylib 0x033c6a21 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Change this line
cell.textLabel.text = [menuItems objectAtIndex:indexPath.row];
with this
cell.textLabel.text = [NSString stringWithFormat:#"%#",[menuItems objectAtIndex:indexPath.row]];
Problem - The reason of the crash is cell.textLabel.text is expecting a NSString value and you are passing NSCFNumber in it so you need to convert NSCFNumber to NSString

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM itemName]: unrecognized selector sent to instance

This is my code for loading data from sqlite file
- (void) loadInitialData{
// Form the query.
NSString *query = #"select * from tasklist";
// Get the results.
if (self.toDoItems != nil) {
self.toDoItems = nil;
}
NSArray *dbResultArray = [[NSArray alloc] initWithArray:[self.dbManager loadDataFromDB:query]];
//Logging for debug purpose
NSLog(#"Result set starts");
for(NSArray *subArray in dbResultArray) {
NSLog(#"Data in array: %#",subArray);
}
NSLog(#"Result set ends");
self.toDoItems = [[NSMutableArray alloc]initWithArray:dbResultArray];
// Reload the table view.
//[self.tblPeople reloadData];
[self.tableView reloadData];
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.dbManager = [[DBManager alloc] initWithDatabaseFilename:#"todotaskdb.sql"];
self.toDoItems = [[NSMutableArray alloc] init];
[self loadInitialData];
}
And I am getting this error using NSLog
2014-11-25 18:24:13.862 ToDoList[3213:60b] Result set ends
2014-11-25 18:24:13.865 ToDoList[3213:60b] -[__NSArrayM itemName]: unrecognized selector sent to instance 0x8c996f0
2014-11-25 18:24:13.900 ToDoList[3213:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM itemName]: unrecognized selector sent to instance 0x8c996f0'
*** First throw call stack:
(
0 CoreFoundation 0x018dc1e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x0165b8e5 objc_exception_throw + 44
2 CoreFoundation 0x01979243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x018cc50b ___forwarding___ + 1019
4 CoreFoundation 0x018cc0ee _CF_forwarding_prep_0 + 14
5 ToDoList 0x00004882 -[XYZToDoListTableViewController tableView:cellForRowAtIndexPath:] + 306
6 UIKit 0x0041411f -[UITableView _createPreparedCellForGlobalRow:withIndexPath:] + 412
7 UIKit 0x004141f3 -[UITableView _createPreparedCellForGlobalRow:] + 69
8 UIKit 0x003f5ece -[UITableView _updateVisibleCellsNow:] + 2428
9 UIKit 0x0040a6a5 -[UITableView layoutSubviews] + 213
10 UIKit 0x0038a964 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
11 libobjc.A.dylib 0x0166d82b -[NSObject performSelector:withObject:] + 70
12 QuartzCore 0x03d4745a -[CALayer layoutSublayers] + 148
13 QuartzCore 0x03d3b244 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
14 QuartzCore 0x03d473a5 -[CALayer layoutIfNeeded] + 160
15 UIKit 0x0044cae3 -[UIViewController window:setupWithInterfaceOrientation:] + 304
16 UIKit 0x00362aa7 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 5212
17 UIKit 0x00361646 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 82
18 UIKit 0x00361518 -[UIWindow _setRotatableViewOrientation:updateStatusBar:duration:force:] + 117
19 UIKit 0x003615a0 -[UIWindow _setRotatableViewOrientation:duration:force:] + 67
20 UIKit 0x0036063a __57-[UIWindow _updateToInterfaceOrientation:duration:force:]_block_invoke + 120
21 UIKit 0x0036059c -[UIWindow _updateToInterfaceOrientation:duration:force:] + 400
22 UIKit 0x003612f3 -[UIWindow setAutorotates:forceUpdateInterfaceOrientation:] + 870
23 UIKit 0x003648e6 -[UIWindow setDelegate:] + 449
24 UIKit 0x0043eb77 -[UIViewController _tryBecomeRootViewControllerInWindow:] + 180
25 UIKit 0x0035a474 -[UIWindow addRootViewControllerViewIfPossible] + 591
26 UIKit 0x0035a5ef -[UIWindow _setHidden:forced:] + 312
27 UIKit 0x0035a86b -[UIWindow _orderFrontWithoutMakingKey] + 49
28 UIKit 0x003653c8 -[UIWindow makeKeyAndVisible] + 65
29 UIKit 0x00315bc0 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 2097
30 UIKit 0x0031a667 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
31 UIKit 0x0032ef92 -[UIApplication handleEvent:withNewEvent:] + 3517
32 UIKit 0x0032f555 -[UIApplication sendEvent:] + 85
33 UIKit 0x0031c250 _UIApplicationHandleEvent + 683
34 GraphicsServices 0x038d1f02 _PurpleEventCallback + 776
35 GraphicsServices 0x038d1a0d PurpleEventCallback + 46
36 CoreFoundation 0x01857ca5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
37 CoreFoundation 0x018579db __CFRunLoopDoSource1 + 523
38 CoreFoundation 0x0188268c __CFRunLoopRun + 2156
39 CoreFoundation 0x018819d3 CFRunLoopRunSpecific + 467
40 CoreFoundation 0x018817eb CFRunLoopRunInMode + 123
41 UIKit 0x00319d9c -[UIApplication _run] + 840
42 UIKit 0x0031bf9b UIApplicationMain + 1225
43 ToDoList 0x00004e0d main + 141
44 libdyld.dylib 0x01e25701 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Ironically, if put below line at the end of viewDidLoad method, then it works.
self.dbManager = [[DBManager alloc] initWithDatabaseFilename:#"todotaskdb.sql"];
Can anyone please tell me what is it that I am doing wrong?
Your toDoItems contains Arrays which contains your items! You're may be getting arrays of the single rows in your database, so you would have to fill them into single toDoItems objects first.
Maybe you could use a factory-like pattern with a method like popToDoItemFromRow:(NSArray *)row which returns your toDoItem for this row.
Then fill an new array in your for (NSArray *subArray in dbResultArray) for these single rows. This new array should you use in you cellForRow...
may be like..
- (void) loadInitialData{
// Form the query.
NSString *query = #"select * from tasklist";
// Get the results.
if (self.toDoItems != nil) {
self.toDoItems = nil;
}
NSArray *dbResultArray = [[NSArray alloc] initWithArray:[self.dbManager loadDataFromDB:query]];
if (self.toDoItems) {
[self.toDoItems removeAllObjects];
}
else {
self.toDoItems = [NSMutableArray new];
}
for(NSArray *subArray in dbResultArray) {
[self.toDoItems addObject:[ToDoItem popToDoItemFromRow:subArray]];
}
// Reload the table view.
//[self.tblPeople reloadData];
[self.tableView reloadData];
}

ios 7.1 Crash when tap on More button on tab bar

I got an crash bug on when tap on More button on tabbar. It just happened on iOS 7.1.
I created a class (MoreTableViewDelegate) which override UITableViewDelegate of More Table View
MoreNavigationController
UIViewController *moreViewController = tabBarController.moreNavigationController.topViewController;
UITableView *moreTableView = (UITableView*)moreViewController.view;
MoreTableViewDelegate *objMoreDelegate=[[MoreTableViewDelegate alloc]initWithDelegate:moreTableView.delegate];
moreTableView.delegate=objMoreDelegate;
This is the detail of MoreTableViewDelegate:
-(MoreTableViewDelegate *) initWithDelegate:(id<UITableViewDelegate>) delegate
{
originalDelegate=delegate;
[super init];
return self;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(isPoweredByMobicart==YES)
{
return 50;
}
else
{
return 60;
}
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
return [originalDelegate tableView:tableView didSelectRowAtIndexPath:indexPath];
}
But when I tap on the More button at tab bar, it's crashed and this is the log:
-[MoreTableViewDelegate _layoutCells]: unrecognized selector sent to instance 0xce7f300
2014-03-25 11:03:12.360 ForeverInt[961:90b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MoreTableViewDelegate _layoutCells]: unrecognized selector sent to instance 0xce7f300'
*** First throw call stack:
(
0 CoreFoundation 0x0336b1e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x02ee18e5 objc_exception_throw + 44
2 CoreFoundation 0x03408243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x0335b50b ___forwarding___ + 1019
4 CoreFoundation 0x0335b0ee _CF_forwarding_prep_0 + 14
5 UIKit 0x00bcc785 -[_UIMoreListTableView didMoveToWindow] + 108
6 UIKit 0x00adb478 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1642
7 UIKit 0x00aed68b -[UIScrollView _didMoveFromWindow:toWindow:] + 65
8 UIKit 0x00adb109 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 763
9 UIKit 0x00ad296f __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 158
10 UIKit 0x00ad27fb -[UIView(Hierarchy) _postMovedFromSuperview:] + 260
11 UIKit 0x00adddd4 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1875
12 UIKit 0x00ad0dba -[UIView(Hierarchy) addSubview:] + 56
13 UIKit 0x00db6c5b -[UINavigationTransitionView transition:fromView:toView:] + 501
14 UIKit 0x00db6a5e -[UINavigationTransitionView transition:toView:] + 55
15 UIKit 0x00bb7577 -[UINavigationController _startTransition:fromViewController:toViewController:] + 3186
16 UIKit 0x00bb78cc -[UINavigationController _startDeferredTransitionIfNeeded:] + 645
17 UIKit 0x00bb84e9 -[UINavigationController __viewWillLayoutSubviews] + 57
18 UIKit 0x00cf90d1 -[UILayoutContainerView layoutSubviews] + 213
19 UIKit 0x00ae0964 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
20 libobjc.A.dylib 0x02ef382b -[NSObject performSelector:withObject:] + 70
21 QuartzCore 0x01d9d45a -[CALayer layoutSublayers] + 148
22 QuartzCore 0x01d91244 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
23 QuartzCore 0x01d910b0 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
24 QuartzCore 0x01cf77fa _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
25 QuartzCore 0x01cf8b85 _ZN2CA11Transaction6commitEv + 393
26 QuartzCore 0x01db65b0 +[CATransaction flush] + 52
27 UIKit 0x00a6f9bb _UIApplicationHandleEventQueue + 13095
28 CoreFoundation 0x032f477f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
29 CoreFoundation 0x032f410b __CFRunLoopDoSources0 + 235
30 CoreFoundation 0x033111ae __CFRunLoopRun + 910
31 CoreFoundation 0x033109d3 CFRunLoopRunSpecific + 467
32 CoreFoundation 0x033107eb CFRunLoopRunInMode + 123
33 GraphicsServices 0x035c85ee GSEventRunModal + 192
34 GraphicsServices 0x035c842b GSEventRun + 104
35 UIKit 0x00a71f9b UIApplicationMain + 1225
36 ForeverInt 0x00086b9d main + 125
37 ForeverInt 0x000030d5 start + 53
)
libc++abi.dylib: terminating with uncaught exception of type NSException
How to solve this issue ? Please help me.

Unable to dequeue a cell with identifier [duplicate]

This question already has answers here:
Assertion failure in dequeueReusableCellWithIdentifier:forIndexPath:
(22 answers)
Closed 8 years ago.
here's the method causing the problem:
-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"TableCell";
TableCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier
forIndexPath:indexPath];
// Configure the cell...
int row = [indexPath row];
Books *book = [myBooks objectAtIndex:row];
cell.bookName.text = book.bookName;
return cell;
}
full log:
2014-02-05 23:19:09.458 Books[1425:a0b] *** Assertion failure in -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:], /SourceCache/UIKit_Sim/UIKit-2903.2/UITableView.m:5251
2014-02-05 23:19:09.471 Books[1425:a0b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier TableCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
*** First throw call stack:
(
0 CoreFoundation 0x017395e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x014bc8b6 objc_exception_throw + 44
2 CoreFoundation 0x01739448 +[NSException raise:format:arguments:] + 136
3 Foundation 0x0109d23e -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
4 UIKit 0x003135e3 -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:] + 170
5 Books 0x000032df -[TableViewController tableView:cellForRowAtIndexPath:] + 127
6 UIKit 0x0031dd2f -[UITableView _createPreparedCellForGlobalRow:withIndexPath:] + 412
7 UIKit 0x0031de03 -[UITableView _createPreparedCellForGlobalRow:] + 69
8 UIKit 0x00302124 -[UITableView _updateVisibleCellsNow:] + 2378
9 UIKit 0x003155a5 -[UITableView layoutSubviews] + 213
10 UIKit 0x00299dd7 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
11 libobjc.A.dylib 0x014ce81f -[NSObject performSelector:withObject:] + 70
12 QuartzCore 0x03af372a -[CALayer layoutSublayers] + 148
13 QuartzCore 0x03ae7514 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
14 QuartzCore 0x03af3675 -[CALayer layoutIfNeeded] + 160
15 UIKit 0x00354ca3 -[UIViewController window:setupWithInterfaceOrientation:] + 304
16 UIKit 0x00273d27 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 5212
17 UIKit 0x002728c6 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 82
18 UIKit 0x00272798 -[UIWindow _setRotatableViewOrientation:updateStatusBar:duration:force:] + 117
19 UIKit 0x00272820 -[UIWindow _setRotatableViewOrientation:duration:force:] + 67
20 UIKit 0x002718ba __57-[UIWindow _updateToInterfaceOrientation:duration:force:]_block_invoke + 120
21 UIKit 0x0027181c -[UIWindow _updateToInterfaceOrientation:duration:force:] + 400
22 UIKit 0x00272573 -[UIWindow setAutorotates:forceUpdateInterfaceOrientation:] + 870
23 UIKit 0x00275b66 -[UIWindow setDelegate:] + 449
24 UIKit 0x00346dc7 -[UIViewController _tryBecomeRootViewControllerInWindow:] + 180
25 UIKit 0x0026b7cc -[UIWindow addRootViewControllerViewIfPossible] + 609
26 UIKit 0x0026b947 -[UIWindow _setHidden:forced:] + 312
27 UIKit 0x0026bbdd -[UIWindow _orderFrontWithoutMakingKey] + 49
28 UIKit 0x0027644a -[UIWindow makeKeyAndVisible] + 65
29 UIKit 0x002298e0 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1851
30 UIKit 0x0022dfb8 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
31 UIKit 0x0024242c -[UIApplication handleEvent:withNewEvent:] + 3447
32 UIKit 0x00242999 -[UIApplication sendEvent:] + 85
33 UIKit 0x0022fc35 _UIApplicationHandleEvent + 736
34 GraphicsServices 0x0368c2eb _PurpleEventCallback + 776
35 GraphicsServices 0x0368bdf6 PurpleEventCallback + 46
36 CoreFoundation 0x016b4dd5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
37 CoreFoundation 0x016b4b0b __CFRunLoopDoSource1 + 523
38 CoreFoundation 0x016df7ec __CFRunLoopRun + 2156
39 CoreFoundation 0x016deb33 CFRunLoopRunSpecific + 467
40 CoreFoundation 0x016de94b CFRunLoopRunInMode + 123
41 UIKit 0x0022d6ed -[UIApplication _run] + 840
42 UIKit 0x0022f94b UIApplicationMain + 1225
43 Books 0x000038bd main + 141
44 libdyld.dylib 0x01d75725 start + 0
45 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
You can directly set the identifier using the storyboard like this.
From the documentation:
Important: You must register a class or nib file using the
registerNib:forCellReuseIdentifier: or
registerClass:forCellReuseIdentifier: method before calling this
method.
You need to register the cell as a usable class for that identifier. Call this after you initialize your UITableView (probably in viewDidLoad)
[self.tableView registerClass:[TableCell class] forCellReuseIdentifier:CellIdentifier]
This assumes CellIdentifier has been moved somewhere where it can be accessed from here.
Try this:
-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"TableCell";
TableCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(!cell)
{
cell = [[[TableCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell...
int row = [indexPath row];
Books *book = [myBooks objectAtIndex:row];
cell.bookName.text = book.bookName;
return cell;
}

Keep getting breakpoint error when trying to run iOS application on iphone simulator with xcode 5

I just started creating a new checklist app for the first time.
So far I have added a Table View object and Table View Cell object to the app's UI in main.storyboard.
I then went to my View Controller header file and made sure to change the superclass type to "UITableViewController".
I then went to my View Controller main file and added the following methods:
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 1;
}
-(UITableViewCell *)tableview:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"ChecklistItem"];
return cell;
}
I keep getting a breakpoint error and cannot get the app to run on the iPhone simulator. I have tried starting from scratch and recreating this app 3 times now and have also tried using different simulators, and still nothing is working.
Whenever I try running the app this is the final output in the debug console:
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Also, here is a link to a screenshot of what my xcode looks like when I try to run the program and get the breakpoint error: http://oi40.tinypic.com/25im3kn.jpg
I have gotten breakpoint errors many times in the past but usually can fix everything by just going to Debug > Deactivate Breakpoints but that is not working for me right now.
Any help is greatly appreciated thank you.
PS. Also, here is the entire output in the debug console log:
2013-12-18 18:25:55.183 Checklists[4910:70b] *** Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:], /SourceCache/UIKit_Sim/UIKit- 2903.23/UITableView.m:6246
2013-12-18 18:25:55.190 Checklists[4910:70b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'
*** First throw call stack:
(
0 CoreFoundation 0x017385e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x014bb8b6 objc_exception_throw + 44
2 CoreFoundation 0x01738448 +[NSException raise:format:arguments:] + 136
3 Foundation 0x0109bfee -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
4 UIKit 0x003123d5 __53-[UITableView _configureCellForDisplay:forIndexPath:]_block_invoke + 426
5 UIKit 0x0028b3ef +[UIView(Animation) performWithoutAnimation:] + 82
6 UIKit 0x0028b438 +[UIView(Animation) _performWithoutAnimation:] + 40
7 UIKit 0x00312226 -[UITableView _configureCellForDisplay:forIndexPath:] + 108
8 UIKit 0x0031863d -[UITableView _createPreparedCellForGlobalRow:withIndexPath:] + 442
9 UIKit 0x003186f3 -[UITableView _createPreparedCellForGlobalRow:] + 69
10 UIKit 0x002fc774 -[UITableView _updateVisibleCellsNow:] + 2378
11 UIKit 0x0030fe95 -[UITableView layoutSubviews] + 213
12 UIKit 0x00294267 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
13 libobjc.A.dylib 0x014cd81f -[NSObject performSelector:withObject:] + 70
14 QuartzCore 0x03b462ea -[CALayer layoutSublayers] + 148
15 QuartzCore 0x03b3a0d4 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
16 QuartzCore 0x03b46235 -[CALayer layoutIfNeeded] + 160
17 UIKit 0x0034f613 -[UIViewController window:setupWithInterfaceOrientation:] + 304
18 UIKit 0x0026e177 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 5212
19 UIKit 0x0026cd16 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 82
20 UIKit 0x0026cbe8 -[UIWindow _setRotatableViewOrientation:updateStatusBar:duration:force:] + 117
21 UIKit 0x0026cc70 -[UIWindow _setRotatableViewOrientation:duration:force:] + 67
22 UIKit 0x0026bd0a __57-[UIWindow _updateToInterfaceOrientation:duration:force:]_block_invoke + 120
23 UIKit 0x0026bc6c -[UIWindow _updateToInterfaceOrientation:duration:force:] + 400
24 UIKit 0x0026c9c3 -[UIWindow setAutorotates:forceUpdateInterfaceOrientation:] + 870
25 UIKit 0x0026ffb6 -[UIWindow setDelegate:] + 449
26 UIKit 0x00341737 -[UIViewController _tryBecomeRootViewControllerInWindow:] + 180
27 UIKit 0x00265c1c -[UIWindow addRootViewControllerViewIfPossible] + 609
28 UIKit 0x00265d97 -[UIWindow _setHidden:forced:] + 312
29 UIKit 0x0026602d -[UIWindow _orderFrontWithoutMakingKey] + 49
30 UIKit 0x0027089a -[UIWindow makeKeyAndVisible] + 65
31 UIKit 0x00223cd0 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1851
32 UIKit 0x002283a8 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
33 UIKit 0x0023c87c -[UIApplication handleEvent:withNewEvent:] + 3447
34 UIKit 0x0023cde9 -[UIApplication sendEvent:] + 85
35 UIKit 0x0022a025 _UIApplicationHandleEvent + 736
36 GraphicsServices 0x036df2f6 _PurpleEventCallback + 776
37 GraphicsServices 0x036dee01 PurpleEventCallback + 46
38 CoreFoundation 0x016b3d65 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
39 CoreFoundation 0x016b3a9b __CFRunLoopDoSource1 + 523
40 CoreFoundation 0x016de77c __CFRunLoopRun + 2156
41 CoreFoundation 0x016ddac3 CFRunLoopRunSpecific + 467
42 CoreFoundation 0x016dd8db CFRunLoopRunInMode + 123
43 UIKit 0x00227add -[UIApplication _run] + 840
44 UIKit 0x00229d3b UIApplicationMain + 1225
45 Checklists 0x00001b7d main + 141
46 libdyld.dylib 0x01d7670d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
PPS. After making your change, my view controller main file now looks like this:
#import "ChecklistsViewController.h"
#interface ChecklistsViewController ()
#end
#implementation ChecklistsViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 1;
}
-(UITableViewCell *)tableview:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"ChecklistItem"]; if(!cell) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:#"ChecklistItem"]; }
return cell;
}
#end
I still get an error and now this is what the console log is showing:
2013-12-18 18:42:14.609 Checklists[5014:70b] *** Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:], /SourceCache/UIKit_Sim/UIKit- 2903.23/UITableView.m:6246
2013-12-18 18:42:14.614 Checklists[5014:70b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'
*** First throw call stack:
(
0 CoreFoundation 0x017395e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x014bc8b6 objc_exception_throw + 44
2 CoreFoundation 0x01739448 +[NSException raise:format:arguments:] + 136
3 Foundation 0x0109cfee -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
4 UIKit 0x003133d5 __53-[UITableView _configureCellForDisplay:forIndexPath:]_block_invoke + 426
5 UIKit 0x0028c3ef +[UIView(Animation) performWithoutAnimation:] + 82
6 UIKit 0x0028c438 +[UIView(Animation) _performWithoutAnimation:] + 40
7 UIKit 0x00313226 -[UITableView _configureCellForDisplay:forIndexPath:] + 108
8 UIKit 0x0031963d -[UITableView _createPreparedCellForGlobalRow:withIndexPath:] + 442
9 UIKit 0x003196f3 -[UITableView _createPreparedCellForGlobalRow:] + 69
10 UIKit 0x002fd774 -[UITableView _updateVisibleCellsNow:] + 2378
11 UIKit 0x00310e95 -[UITableView layoutSubviews] + 213
12 UIKit 0x00295267 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
13 libobjc.A.dylib 0x014ce81f -[NSObject performSelector:withObject:] + 70
14 QuartzCore 0x03b472ea -[CALayer layoutSublayers] + 148
15 QuartzCore 0x03b3b0d4 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
16 QuartzCore 0x03b47235 -[CALayer layoutIfNeeded] + 160
17 UIKit 0x00350613 -[UIViewController window:setupWithInterfaceOrientation:] + 304
18 UIKit 0x0026f177 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 5212
19 UIKit 0x0026dd16 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 82
20 UIKit 0x0026dbe8 -[UIWindow _setRotatableViewOrientation:updateStatusBar:duration:force:] + 117
21 UIKit 0x0026dc70 -[UIWindow _setRotatableViewOrientation:duration:force:] + 67
22 UIKit 0x0026cd0a __57-[UIWindow _updateToInterfaceOrientation:duration:force:]_block_invoke + 120
23 UIKit 0x0026cc6c -[UIWindow _updateToInterfaceOrientation:duration:force:] + 400
24 UIKit 0x0026d9c3 -[UIWindow setAutorotates:forceUpdateInterfaceOrientation:] + 870
25 UIKit 0x00270fb6 -[UIWindow setDelegate:] + 449
26 UIKit 0x00342737 -[UIViewController _tryBecomeRootViewControllerInWindow:] + 180
27 UIKit 0x00266c1c -[UIWindow addRootViewControllerViewIfPossible] + 609
28 UIKit 0x00266d97 -[UIWindow _setHidden:forced:] + 312
29 UIKit 0x0026702d -[UIWindow _orderFrontWithoutMakingKey] + 49
30 UIKit 0x0027189a -[UIWindow makeKeyAndVisible] + 65
31 UIKit 0x00224cd0 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1851
32 UIKit 0x002293a8 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
33 UIKit 0x0023d87c -[UIApplication handleEvent:withNewEvent:] + 3447
34 UIKit 0x0023dde9 -[UIApplication sendEvent:] + 85
35 UIKit 0x0022b025 _UIApplicationHandleEvent + 736
36 GraphicsServices 0x036e02f6 _PurpleEventCallback + 776
37 GraphicsServices 0x036dfe01 PurpleEventCallback + 46
38 CoreFoundation 0x016b4d65 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
39 CoreFoundation 0x016b4a9b __CFRunLoopDoSource1 + 523
40 CoreFoundation 0x016df77c __CFRunLoopRun + 2156
41 CoreFoundation 0x016deac3 CFRunLoopRunSpecific + 467
42 CoreFoundation 0x016de8db CFRunLoopRunInMode + 123
43 UIKit 0x00228add -[UIApplication _run] + 840
44 UIKit 0x0022ad3b UIApplicationMain + 1225
45 Checklists 0x00002aed main + 141
46 libdyld.dylib 0x01d7770d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
The problem is that the code dequeueReusableCellWithIdentifier is not returning a cell.
Check if your cell in the XIB as the Reuse Identifier set to "ChecklistItem"
If the dequeueReusableCellWithIdentifier returns nil create a new cell.
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"ChecklistItem"];
if(!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:#"ChecklistItem"];
}
That should fix your problem.

Resources