Reputation: 6614
I have a rootViewController and have a UIButton that's created programmatically. I want this UIButton to display another view controller. For some reason it crashes with the following error:
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_TutorialViewController", referenced from: objc-class-ref in RootViewController.o ld: symbol(s) not found for architecture i386 collect2: ld returned 1 exit status
here's the code that creates an Info UIButton. this code is in the loadView method:
// Create a Button to get Help
UIButton *helpButton = [UIButton buttonWithType:UIButtonTypeInfoDark ] ;
CGRect buttonRect = helpButton.frame;
// CALCulate the bottom right corner
buttonRect.origin.x = self.view.frame.size.width - buttonRect.size.width - 8;
buttonRect.origin.y = buttonRect.size.height - 8;
[helpButton setFrame:buttonRect];
[helpButton addTarget:self action:@selector(doHelp:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:helpButton];
}
Here's the action to transisition to another view controller:
- (IBAction)doHelp:(id)sender{
NSLog(@"help button pressed");
TutorialViewController *sampleView = [[[TutorialViewController alloc] init] autorelease];
[sampleView setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentModalViewController:sampleView animated:YES];
}
thanks for any help.
Upvotes: 0
Views: 347
Reputation: 341
instead of (IBAction)doHelp:(id)sender
you must write (void)doHelp
....try this:)
Upvotes: 1
Reputation: 307
very basic but somtime we may miss it :) have you declared same method in .h file?
Upvotes: 0
Reputation: 316
adig is probably right.
Also, that technically isn't a "crash." It "fails to build, with this linker error." You can tell that it's a linker error because it said, "ld returned 1 exit status". ld is the linker.
Under the covers, XCode compiles and links your code before running it. If it fails during compilation or linking, it's a "build failure," not a "crash." A crash is when the application built, but then suddenly stopped at run time. One common cause of this is accessing a nil pointer.
Upvotes: 5
Reputation: 176
Are you #importing the .h file, not the .m file?
The problem is not with your UIButton, the problem is the TutorialViewController class is not being compiled correctly.
Upvotes: 0
Reputation: 4057
Check in your Target settings, on Build Phases under Compile Sources list that you have TutorialViewController.m file in the list.
Upvotes: 2