objective-cxcodexcode4.3nibloadnibnamed

Xcode 4: Loading a Nib in a method in a different file


sorry if this question is elementary, but I've been stuck on this bug for the past 2 days & I haven't been able to get past it. I'm using Xcode 4.3.2

I'm trying to load a nib named AController.xib in a method called "- (void) process" in the file named BController.m

To be clear, I copied ./A/AController.xib (which is a UIView), ./A/AController.m, ./A/AController.h to the directory ./B

I only mention this because I'm not sure if it matters for my question.

Currently, my flow works as flows (which could be my problem):

The error I get here is "Thread 1: signal SIGABRT" in main.m I've also tried (option 2),

AController *myView = [[AController alloc] initWithFrame:self.view.bounds];
[self.view addSubview:myView];
[AController release];

And (option 3)

AController * vc = [[AController alloc] initWithNibBundle:@"AController" bundle:nil];    [self.nc pushViewController:vc animated:NO];

I get the same error for all 3 choices. Each option was tried in the method "process". "process" is written in B.m. Can anyone offer some help so that I may figure this out? Any guidance as to why these options failed would be very helpful for my understanding and would be much appreciated. Thanks for helping a noob!


Solution

  • If AController is a UIView subclass, it cannot load a NIB. Verify it is in fact a controller, but from the initWithFrame and the way you are adding it to a view, it looks like it is not, or is being handled incorrectly.