SIGABRT - What is happening? Label of Death - sigabrt

I am coding an app that involves loading data from NSUserDefaults. So when I have confirmed that the passed integer was 1, I want it to display a certain text. However when I don't have a UILabel on my .Xib. It is fine, but as soon as I add a outlet for the label, place it onto the .Xib and link it all up, it comes up with SIGABRT
-(void)viewDidLoad {
int page = [[[NSUserDefaults standardUserDefaults] objectForKey:#"Page"] integerValue];
NSString *log = [NSString stringWithFormat:#"%d", page];
NSLog(log);
if (page == 1 ) {
NSLog(#"redstone block");
title.text = #"redstone Blcok";
}
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
The error I get:
2013-04-09 18:16:13.910 redstoneGuide[94905:c07] -[UILabel copyWithZone:]: unrecognized selector sent to instance 0x756b910
2013-04-09 18:16:13.911 redstoneGuide[94905:c07] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UILabel copyWithZone:]: unrecognized selector sent to instance 0x756b910'
* First throw call stack:
(0x1599012 0x12a6e7e 0x16244bd 0x1588bbc 0x158894e 0x12baae9 0x2cd32b 0xcd45be 0xcd40e7 0xcfeb58 0x408019 0x12ba663 0x159445a 0x406b1c 0x2cb7e7 0x2cbdc8 0x2cbff8 0x2cc232 0x2d7c25 0x4d73a3 0x2d4ee3 0x2d5167 0x33cc 0x12ba705 0x1ee2c0 0x1ee258 0x2af021 0x2af57f 0x2ae6e8 0x4b21d3 0x1561afe 0x1561a3d 0x153f7c2 0x153ef44 0x153ee1b 0x25fa7e3 0x25fa668 0x1eaffc 0x1fcd 0x1ef5)
libc++abi.dylib: terminate called throwing an exception
(lldb)

It turns out you cannot do
Iboutlet uilabel *title;
The name title causes the application to crash.
However, the below works.
Iboutlet uilabel *Gtitle

Related

return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]

I'm trying to make a free music app and i am trying to put in mp4 video of the music. But the second button just makes it crash with return UIApplicationMain(argc, argv, nil,
NSStringFromClass([AppDelegate class] The code i'm using is
- (IBAction)playButton:(id)sender {
NSString *stringPath = [[NSBundle mainBundle]pathForResource:#"Under_Control" ofType:#"mp3"];
NSURL *url = [NSURL fileURLWithPath:stringPath];
mpc = [[MPMoviePlayerController alloc]initWithContentURL:url];
[mpc setMovieSourceType:MPMovieSourceTypeFile];
[[self view]addSubview:mpc.view];
[mpc setFullscreen:YES];
[mpc play];
And also put
{
MPMoviePlayerController *mpc;
}
Under #interface ViewController;
A crash in that location simply means there was an uncaught exception somewhere in your code. Adding an exception breakpoint in Xcode (Exception breakpoints) will make the program crash on the line that is throwing the exception.
Edit: another thought, are you getting a valid URL variable back? I'm guessing that passing nil to the MPMoviePlayerController is the problem you are having.
If you are using storyboards, check to make sure that you don't have duplicate referencing outlets that you hooked up, or referencing outlets that shouldn't be there anymore that don't have matching methods in your code anymore.

unrecognized selector sent to instance for Paul Hegarty's CS193P

I'm following Paul Hegarty's CS193P course video (lecture #4 # 1:05:40 mark) and ran into problems. Please help debug this 'unrecognized selector sent to instance' error. The view has three objects - see image (https://docs.google.com/file/d/0B453_F6cDmYzMG1OQW93WVptYUU/edit?usp=sharing)
The code
// AttributeViewController.m
// Attribute
#import "AttributeViewController.h"
#interface AttributeViewController ()
#property (weak, nonatomic) IBOutlet UILabel *label; // collection of words
#property (weak, nonatomic) IBOutlet UIStepper *selectedWordStepper; // stepper
#property (weak, nonatomic) IBOutlet UILabel *selectedWordLabel; // selected word from label
#end
#implementation AttributeViewController
- (NSArray *)wordList
{
NSArray *wordList = [[self.label.attributedText string] componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if ([wordList count]) {
return wordList;
} else {
return #[#""];
}
}
- (NSString *)selectedWord
{
return [self wordList][(int)self.selectedWordStepper.value];
}
- (IBAction)updateSelectedWord {
self.selectedWordStepper.maximumValue = [[self wordList] count]-1;
self.selectedWordLabel.text = [self selectedWord];
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self updateSelectedWord];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#end
The error
2013-03-03 18:03:28.948 Attribute[74205:c07] -[AttributeViewController updateSelectedWord:]: unrecognized selector sent to instance 0x71b93a0
2013-03-03 18:03:28.952 Attribute[74205:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AttributeViewController updateSelectedWord:]: unrecognized selector sent to instance 0x71b93a0'
*** First throw call stack:
(0x1c91012 0x10cee7e 0x1d1c4bd 0x1c80bbc 0x1c8094e 0x10e2705 0x162c0 0x16258 0xd7021 0xd757f 0xd7056 0x42b195 0x42ae91 0xd6696 0x45cef 0x45f02 0x23d4a 0x15698 0x1becdf9 0x1c14f3f 0x1c1496f 0x1c37734 0x1c36f44 0x1c36e1b 0x1beb7e3 0x1beb668 0x12ffc 0x25cd 0x24f5)
libc++abi.dylib: terminate called throwing an exception
(lldb) gdb
I have really not seen direct calls to IBAction methods before. IBAction methods are connected to actions in your View (buttons, etc.) and are triggered when these buttons, etc.. are clicked.
If updateSelectedWord is an internal method, just replace IBAction with void:
(void)updateSelectedWord
Hope this helps.

xcode IBAction unrecognized selector sent to instance

i have a problem with and IBAction in my code. Everytime i click the button this Exception appears:
2013-01-15 22:25:00.798 FitnessApp[3478:c07] -[__NSCFString cancel:]: unrecognized selector sent to instance 0x93a7e50
2013-01-15 22:25:00.800 FitnessApp[3478:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString cancel:]: unrecognized selector sent to instance 0x93a7e50'
i already searched for this error. however the solutions here on stackoverflow didnt work.
My connections are all correctly set. no dublicate connections or something like that.
My Code:
- (void)viewDidLoad {
[super viewDidLoad];
[self setTitle:NSLocalizedString(#"Placeholder_Description", nil)];
[self.navigationController setToolbarHidden:NO];
[self.navigationController.toolbar setTintColor:[UIColor colorWithRed:0 green:0 blue:0 alpha:1]];
[self.buttonCancel setTarget:NSLocalizedString(#"Cancel_Button", nil)];
[self.buttonSave setTarget:NSLocalizedString(#"Save_Button", nil)];
[self.textViewDescription.layer setBorderColor:[[UIColor grayColor] CGColor]];
[self.textViewDescription.layer setBorderWidth:1.0];
[self.textViewDescription.layer setCornerRadius:8.0f];
[self.textViewDescription.layer setMasksToBounds:YES];
[self.textViewDescription setText:[self textViewDescriptionText]];
}
- (IBAction)cancel:(id)sender {
[self dismissViewControllerAnimated:YES completion:nil];
}
- (IBAction)save:(id)sender {
[self.delegate doSaveDescription:self withDescription:[self.textViewDescription text]];
[self dismissViewControllerAnimated:YES completion:nil];
}
i made some NSLogs to find out that the IBAction is the problem because there never was an output after clicking the buttons, just the exception.
So what can i do if the connections are correctly set?

cocos2d ccmenuitem can't access variables, ends with SIGABRT

I have this code below. The thing is, each time I click on the "SPIN" ccmenuitem, the program crashes with a "Program received signal: SIGABRT"
Here's the output in the console:
2011-07-29 13:52:52.906 HelloWorld[1031:207] -[NSCFString shuffle]: unrecognized selector sent to instance 0x6833c90
2011-07-29 13:52:52.976 HelloWorld[1031:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString shuffle]: unrecognized selector sent to instance 0x6833c90'
I don't know what's wrong, my
And here is my code.
`#import <Foundation/Foundation.h>
#import "cocos2d.h"
#interface GameScene : CCLayer {
NSMutableArray * answersArray; //holds all valid answers
NSMutableArray * lettersArray; //holds placement of letters to display
NSMutableArray * userAnswerArray; //holds user's answer to check and submit
NSString * THEWORD; //the word
}
+(id) scene;
....
- (void) spinWord;
- (void) playWord;
#end`
And this implementation:
`
#implementation GameScene
+(id) scene { ... }
-(id) init
{
if( (self=[super init])) {
...//everything is initialized
[self initImages]
...
}
}
- (void) initImages
{
....
CCMenuItem *menuItem1 = [CCMenuItemImage itemFromNormalImage:#"PLAYunselected.png" selectedImage:#"PLAYselected.png" target:nil selector:#selector(onPlayWord)];
CCMenuItem *menuItem2 = [CCMenuItemImage itemFromNormalImage:#"SPINunselected.png" selectedImage:#"SPINselected.png" target:self selector:#selector(spinWord)];
CCMenu *menu = [CCMenu menuWithItems:menuItem1, menuItem2, nil];
[menu alignItemsHorizontally];
menu.position = ccp(72, 198);
[self addChild:menu z:2];
}
- (void) spinWord{
//NSLog(#"%#",lettersArray); <---if I uncomment this line, I get an EXC_BAD_ACCESS message instead
[lettersArray shuffle]; // <--- this line causes the SIGABRT signal, even if it's initialized.
NSLog(#"%#",lettersArray);
...
}
#end
`
Please help me out. Is this a memory management problem? If so, how do I fix it?
Thank you very much!
That error always means exactly what it reads like it means. You have sent a message to an object that does not understand that message (meaning the object does not have a method to handle such a request). This however can also mean you are sending a message to an object that does not exist.
If you try to access a bad array index (or the index of an array that does not actually exist) you get bad access. If you try to access a method that does not exist, or a method of an object that does not exist, you get a unrecognized selector message.
I do not see you allocating or initializing your arrays. I don't know what shuffle is, you have not posted code for it. It may be a built in method for all I know. I am fairly certain that all you need to do is allocate and initialize your arrays.
NSMutableArray * answersArray = [[NSMutableArray alloc] init];
// And so on with your other arrays.
I noticed you have target:nil instead of target:self on menuItem1. The error is happening on menuItem2, so I'm not sure that's relevant. I was getting a very similar error just the other day, and it came down to the wrong target. Everything else in your code looks OK to me at first glance.

Exception in mouseDown method

I am doing drag and drop with NSView.
In the object to be dragged, which is subclass of NSView, I implemented mouseDown: method as follows:
#try {
NSPoint location;
NSSize size ;
NSPasteboard *pb = [NSPasteboard pasteboardWithName:#"CameraIconContainer"];
location.x = ([self bounds].size.width - size.width)/2 - 21.0;
location.y = ([self bounds].size.height - size.height)/2 - 7.0;
NSLog(#"mouseDown: location- (%f, %f)",location.x,location.y);
NSDictionary *iconViewDict = [[NSDictionary alloc] initWithObjectsAndKeys:[cameraNo stringValue],#"cameraNo",nil];
NSLog(#"iconViewDict - %#",iconViewDict);
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:iconViewDict];
[pb declareTypes:[NSArray arrayWithObject:IconDragDataType] owner:self];
[pb setData:data forType:IconDragDataType];
[self dragImage:[NSImage imageNamed:#"camera_icon.png"] at:location offset:NSZeroSize event:e pasteboard:pb source:self slideBack:YES];
}
#catch (NSException * e) {
NSLog(#"CameraIconView (-mouseDown:), error - %#",e);
}
Most of the time it is working fine but problem is- sometimes it is raising this
exception:Invalid parameter not
satisfying: theWriteStream != NULL
in the mouseDown: method, because of it the dragged image continuously appears over screen, which does not disappear even if some other window is selected.
Can anyone suggest me why is it occurring and how can I resolve it?
Thanks,
Miraaj
exception:Invalid parameter not satisfying: theWriteStream != NULL
That sort of exception comes from an assertion. Something is about to try to write to a stream, and asserted that it has a stream to write to. When the assertion fails, that means that the condition was untrue; in this case, it means that it did not have a stream to write to.
I don't see any stream-related code in the sample you provided, so it's either somewhere else in your app or somewhere within a framework you're using. You should turn on “Stop on Objective-C exceptions” in Xcode, then run your app under the debugger until the exception occurs, then look at the stack trace in the debugger to see exactly what threw the exception.

Resources