dimanche 28 juin 2015

Custom View Controller on launching

After a few years off the grid, I'm back programming a quick IOS application and I have to say it seems I need to get back on track :D

I'm just trying to set-up a login view upon launching the application and I am stuck with the following issue on which I've read about a lot but could not fix it. Simulation stops on the main.m (@autoreleasepool). FYI, I am not using xib or storyboard as I'm trying to do everything programmatically.

libc++abi.dyLibL terminating with uncaught exception of type NSException

It is probably coming from one of the following. LoginViewController.h

@interface LoginViewController : UIViewController 
@end

Test1 / LoginViewController.m I guess there should be a init method defined from UIViewController so I would not need to define one here.

@implementation LoginViewController
@end

Test2 / LoginViewController.m Trying to override with my custom init function. No luck as well.

@implementation LoginViewController
- (id) init
{
self = [super initWithNibName:nil bundle:nil];
return self;
}
@end

AppDelegate.m (didfinishlaunching function)

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
LoginViewController *loginViewController = [[LoginViewController init] alloc];
// error here
self.window.rootViewController = loginViewController;
[self.window makeKeyAndVisible];
return YES;

Not sure exactly what went wrong here but it crashes right after seeing a black iphone screen on the simulator... Any help appreciated ;)

Thanks.

Aucun commentaire:

Enregistrer un commentaire