Fredrik
Fredrik

Reputation: 63

Creating Apple's official ToDoList in a Single view application

I am making a To Do List to have in my single view application, and I have come pretty far, and I am on the third tutorial. However, here is where I am facing difficulties.

I did everything 'by the book', except in the beginning, which was not possible.

This is what Apple wants me to enter in the AppDelegate.m file:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    return YES;
}

I have done that, but Xcode does not let me put in the ending curly bracket without giving me errors.

The beginning of my AppDelegate.m file looks like this, and I am not getting any errors:

#import "AppDelegate.h"
#import "LessonController.h"

@implementation AppDelegate

@synthesize managedObjectContext = _managedObjectContext;
@synthesize managedObjectModel = _managedObjectModel;
@synthesize persistentStoreCoordinator = _persistentStoreCoordinator;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    LessonController *lessonController = [LessonController sharedController];
    lessonController.managedObjectContext = self.managedObjectContext;
    return YES;
}

When I now run the app, it crashes, and this is the reason according to the debugger:

return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));

This is specifically what the debugger tells me:

2014-08-01 17:13:49.703 *Name of my app* [18698:60b] *** Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:], /SourceCache/UIKit_Sim/UIKit-2935.137/UITableView.m:6509
2014-08-01 17:13:49.707 *Name of my app* [18698:60b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'
*** First throw call stack:
(
    0   CoreFoundation                      0x01bd11e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x019508e5 objc_exception_throw + 44
    2   CoreFoundation                      0x01bd1048 +[NSException raise:format:arguments:] + 136
    3   Foundation                          0x0029e4de -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
    4   UIKit                               0x007c1d7f __53-[UITableView _configureCellForDisplay:forIndexPath:]_block_invoke + 426
    5   UIKit                               0x0073681f +[UIView(Animation) performWithoutAnimation:] + 82
    6   UIKit                               0x00736868 +[UIView(Animation) _performWithoutAnimation:] + 40
    7   UIKit                               0x007c1bd0 -[UITableView _configureCellForDisplay:forIndexPath:] + 108
    8   UIKit                               0x007c913d -[UITableView _createPreparedCellForGlobalRow:withIndexPath:] + 442
    9   UIKit                               0x007c91f3 -[UITableView _createPreparedCellForGlobalRow:] + 69
    10  UIKit                               0x007aaece -[UITableView _updateVisibleCellsNow:] + 2428
    11  UIKit                               0x007bf6a5 -[UITableView layoutSubviews] + 213
    12  UIKit                               0x0073f964 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
    13  libobjc.A.dylib                     0x0196282b -[NSObject performSelector:withObject:] + 70
    14  QuartzCore                          0x0472445a -[CALayer layoutSublayers] + 148
    15  QuartzCore                          0x04718244 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
    16  QuartzCore                          0x047180b0 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
    17  QuartzCore                          0x0467e7fa _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
    18  QuartzCore                          0x0467fb85 _ZN2CA11Transaction6commitEv + 393
    19  QuartzCore                          0x0473d5b0 +[CATransaction flush] + 52
    20  UIKit                               0x006edce5 _afterCACommitHandler + 131
    21  CoreFoundation                      0x01b9936e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
    22  CoreFoundation                      0x01b992bf __CFRunLoopDoObservers + 399
    23  CoreFoundation                      0x01b77254 __CFRunLoopRun + 1076
    24  CoreFoundation                      0x01b769d3 CFRunLoopRunSpecific + 467
    25  CoreFoundation                      0x01b767eb CFRunLoopRunInMode + 123
    26  GraphicsServices                    0x039995ee GSEventRunModal + 192
    27  GraphicsServices                    0x0399942b GSEventRun + 104
    28  UIKit                               0x006d0f9b UIApplicationMain + 1225
    29  *Name of my app*                     0x0001830d main + 141
    30  libdyld.dylib                       0x02218701 start + 1
    31  ???                                 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

Any ideas on how to solve this issue? I

Upvotes: 0

Views: 79

Answers (1)

kljhanson
kljhanson

Reputation: 136

Your LessionController is a delegate or owns an object that is a delegate for a UITableView that does not return a valid UITableViewCell from the method tableView:cellForRowAtIndexPath. You should look at the examples that are outlined on Apple's guide to populating data for UITableViews here.

Upvotes: 1

Related Questions