0

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:

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.

Randika Vishman
  • 7,983
  • 3
  • 57
  • 80
gotye
  • 958
  • 2
  • 14
  • 33

1 Answers1

1

Change this line

LoginViewController *loginViewController = [[LoginViewController init] alloc];

To

LoginViewController *loginViewController = [[LoginViewController alloc] init];

Mukesh
  • 3,680
  • 1
  • 15
  • 32
  • I don't even know what to say ... Now it works. Like I said I really need to get back into it ... Thanks a lot! I'll accept as answer as soon as it's allowed. – gotye Jun 29 '15 at 05:41