Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Heisler98

macrumors member
Original poster
Oct 30, 2010
73
0
I'm building this simple app (soon to be complex) and it's a Tab Bar app, 3 sections, and I'm having a simple button that pops up an alert. Really simple.

I put up all of the code and linked in my methods within IB, and I've set everything, instances, variables, everything, and yet I receive this error:

Thread 1: Program received signal SIGABRT

Here's my code for the header file for my third view:
Code:
@interface ThirdViewController : UIViewController {
    IBOutlet UIButton *alertButton;
}
@property (nonatomic, retain) IBOutlet UIButton *alertButton; 

// public methods for implementation (in case: hitting button)
-(IBAction) alertMe;

@end

And here's for the implementation file:
Code:
@implementation ThirdViewController
@synthesize alertButton;

-(IBAction) alertMe {

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert from Console" message:@"Your button action has been received" delegate:nil cancelButtonTitle:@"Send Confirm" otherButtonTitles:nil];

    
    [alert show];
    [alert release];  
}

SIGABRT means something fatal has happened & it has to abort, right? And it (of course) only happens when I activate the alertMe method (click the button). Am I using outdated code or something? B/c I'm currently learning off of Lynda.com's 3.0 SDK tutorials.

Much appreciated,
Hunter

BTW, here's the entire source code folder, JIC:
http://www.huntereisler.com/xcodeproj/TabBar

If you can't get the zip file (my cpanel isn't working right) PM me or email me at heisler98@gmail.com
 
SIGABRT is a runtime exception and indicates that your code has failed an assertion. See the NSAssert() macro. That's almost certainly how apple implements this. On iOS, by default, your app crashes when a runtime exception is thrown.

When this happens there is more info in the debugger console that tells you what has happened. You need to look at that text to figure this out. It will start with the text "Terminating app..." If you look at that and don't understand it then post it here. Also, check the Run > Stop on Objective C exceptions menu item. When your app throws an exception the debugger will stop and you can look through the stack to find the exact line in your code that causes the problem.
 
I'm using Xcode 4, so it's a bit different than what you're specifying, but I copied this from the debug gcc console:
Code:
2011-03-15 22:24:09.315 TabBar[89891:207] -[UIViewController alertMe]: unrecognized selector sent to instance 0x4b41b70
2011-03-15 22:24:09.318 TabBar[89891:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController alertMe]: unrecognized selector sent to instance 0x4b41b70'
*** Call stack at first throw:
(
	0   CoreFoundation                      0x00dc25a9 __exceptionPreprocess + 185
	1   libobjc.A.dylib                     0x00f16313 objc_exception_throw + 44
	2   CoreFoundation                      0x00dc40bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
	3   CoreFoundation                      0x00d33966 ___forwarding___ + 966
	4   CoreFoundation                      0x00d33522 _CF_forwarding_prep_0 + 50
	5   UIKit                               0x000144fd -[UIApplication sendAction:to:from:forEvent:] + 119
	6   UIKit                               0x000a4799 -[UIControl sendAction:to:forEvent:] + 67
	7   UIKit                               0x000a6c2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
	8   UIKit                               0x000a57d8 -[UIControl touchesEnded:withEvent:] + 458
	9   UIKit                               0x00038ded -[UIWindow _sendTouchesForEvent:] + 567
	10  UIKit                               0x00019c37 -[UIApplication sendEvent:] + 447
	11  UIKit                               0x0001ef2e _UIApplicationHandleEvent + 7576
	12  GraphicsServices                    0x00ffb992 PurpleEventCallback + 1550
	13  CoreFoundation                      0x00da3944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
	14  CoreFoundation                      0x00d03cf7 __CFRunLoopDoSource1 + 215
	15  CoreFoundation                      0x00d00f83 __CFRunLoopRun + 979
	16  CoreFoundation                      0x00d00840 CFRunLoopRunSpecific + 208
	17  CoreFoundation                      0x00d00761 CFRunLoopRunInMode + 97
	18  GraphicsServices                    0x00ffa1c4 GSEventRunModal + 217
	19  GraphicsServices                    0x00ffa289 GSEventRun + 115
	20  UIKit                               0x00022c93 UIApplicationMain + 1160
	21  TabBar                              0x00002939 main + 121
	22  TabBar                              0x000028b5 start + 53
)
terminate called after throwing an instance of 'NSException'
sharedlibrary apply-load-rules all
Current language:  auto; currently objective-c

It says "..throwing an instance of 'NSException', basically meaning that it's trying to throw an exception for something, right?

The error (so sorry, should've posted this) comes up in an error in the main.m file, with this code:
Code:
int main(int argc, char *argv[])
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    int retVal = UIApplicationMain(argc, argv, nil, nil);
    [pool release];
    return retVal;
}
The int retVal = UIApplicationMain(argc, argv, nil, nil); is the line where the error SIGABRT occurs.

Any help? Still not exactly sure where my error is.

Oh: here's this: 2011-03-15 22:24:09.318 TabBar[89891:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController alertMe]: unrecognized selector sent to instance 0x4b41b70'

Guess it's in my method....still not sure.
 
2011-03-15 22:24:09.318 TabBar[89891:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController alertMe]: unrecognized selector sent to instance 0x4b41b70'
Right. So your button is trying to send the alertMe message to an instance of UIViewController. But your view controller is supposed to be of class ThirdViewController. And really there's no point of there being a UIViewController instance in anyone's app. Only subclasses are of any use. What is the Class of the View Controller in the nib? I downloaded your project. Look in MainWindow.xib, where the view controllers are built.
 
Right. So your button is trying to send the alertMe message to an instance of UIViewController. But your view controller is supposed to be of class ThirdViewController. And really there's no point of there being a UIViewController instance in anyone's app. Only subclasses are of any use. What is the Class of the View Controller in the nib? I downloaded your project. Look in MainWindow.xib, where the view controllers are built.

When I'm in the Identity Inspector (and mind that I'm using Xcode 4) and I'm looking at my classes with my Tab Bar Controller selected in the left pane in the Mainwindow nib, my class is UIViewController when I click on the third button (Stuff). So I should change this to ThirdViewController?
 
Hi,

I also receive the message : Program received signal "SIGBART".
However, there's no error message in the debug window.

I totally dont know what's going on.

Please help.
 
To those whom it may concern...

My fix:

Go to the actual .xcodeproj file when in Xcode

Change "Main Interface" to nothing

That worked for me, but that was my bad in the first place for changing it :D
 
Sigabrt

I get this little nice error when i'm switching .xib files:

#import <UIKit/UIKit.h>

int main(int argc, char *argv[]) {

NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil); ----This is the error line-
[pool release];
return retVal;
}
 
That doesn't mean that your error happens there, it crashes somewhere else.
Try putting breakpoints, see where till where your code goes, then fix the error where it crashes ;p
Or put NSLog's everywhere, and I mean everywhere, so u can exactly see, what it does, when it does it, what's called last.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.