I am new to xcode and following this RestKit tutorial: https://github.com/RestKit/RKGist/blob/master/TUTORIAL.md I have gone through it once succesfully. I am going through it again and customizing it to fit my needs and for some reason, very early on (even before I've made any real deviations) the app crashes on the simulator. I set up the data model, configured RestKit and CoreData, and then failed the first simulation in the tut. This is the error I get when I try to run it:
2013-06-09 18:37:10.121 marko1[16183:c07] I restkit:RKLog.m:34 RestKit logging initialized...
2013-06-09 18:37:10.148 marko1[16183:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter'
*** First throw call stack:
(0x1b24012 0x1949e7e 0x1b23deb 0x13609b1 0x136093b 0x26db 0x88b157 0x88b747 0x88c94b 0x89dcb5 0x89ebeb 0x890698 0x25c0df9 0x25c0ad0 0x1a99bf5 0x1a99962 0x1acabb6 0x1ac9f44 0x1ac9e1b 0x88c17a 0x88dffc 0x25dd 0x2505 0x1)
libc++abi.dylib: terminate called throwing an exception
And above, it displays this line of code from the main.m file:
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
I can't figure it out because I cloned the code from a functional version I created and it still crashes. Any help would be greatly - even if its just explaining what this means abstractly and how to approach attacking this problem. Thanks in advance!
Here is the AppDelegate.m file where I call NSURL (and where the exception breakpoints direct me).
#import "AppDelegate.h"
#import <RestKit/RestKit.h>
#import "MasterViewController.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSError *error = nil;
NSURL *modelURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Marko1" ofType:@"momd"]];
NSManagedObjectModel *managedObjectModel = [[[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL] mutableCopy];
RKManagedObjectStore *managedObjectStore = [[RKManagedObjectStore alloc] initWithManagedObjectModel:managedObjectModel];
//Initialize the Core Data Stack
[managedObjectStore createPersistentStoreCoordinator];
NSPersistentStore __unused *persistentStore = [managedObjectStore addInMemoryPersistentStore:&error];
NSAssert(persistentStore, @"Failed to add persistent store: %@", error);
[managedObjectStore createManagedObjectContexts];
//Set the default store shared instance
[RKManagedObjectStore setDefaultStore:managedObjectStore];
//Override point for customization after application launch.
UINavigationController *navigationController = (UINavigationController *)self.window.rootViewController;
MasterViewController *controller = (MasterViewController *)navigationController.topViewController;
controller.managedObjectContext = managedObjectStore.mainQueueManagedObjectContext;
return YES;
}
@end