Thread 1: signal SIGABRT in main.m file - objective-c

I need some help in Xcode. I am getting the error Thread 1: SIGABRT and it is pointing to the main.m file. I set up the exception breakpoint and it still stops in the main.m file.
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
#import "AppDelegate.h"
int main(int argc, char *argv[])
{
#autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
That is the code that I have in my main.m file. Can someone please help me with this error.
The full error is:
2013-09-07 23:41:05.440 save the jewel 5[86090:c07] -[game pause:]: unrecognized selector sent to instance 0x845ece0
2013-09-07 23:41:09.460 save the jewel 5[86090:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[game pause:]: unrecognized selector sent to instance 0x845ece0'
*** First throw call stack:
(0x1693012 0x13a0e7e 0x171e4bd 0x1682bbc 0x168294e 0x13b4705 0x2e82c0 0x2e8258 0x3a9021 0x3a957f 0x3a86e8 0x317cef 0x317f02 0x2f5d4a 0x2e7698 0x26f5df9 0x26f5ad0 0x1608bf5 0x1608962 0x1639bb6 0x1638f44 0x1638e1b 0x26f47e3 0x26f4668 0x2e4ffc 0x23c2 0x22f5)
libc++abi.dylib: terminate called throwing an exception
In my game.m file I have:
-(void)pauseLayer:(CALayer*)layer{
CFTimeInterval pausedTime = [layer convertTime:CACurrentMediaTime() fromLayer:nil];
layer.speed = 0.0;
layer.timeOffset = pausedTime;
}
-(void)resumeLayer:(CALayer*)layer{
CFTimeInterval pausedTime = [layer timeOffset];
layer.speed = 1.0;
layer.timeOffset = 0.0;
layer.beginTime = 0.0;
CFTimeInterval timeSincePause = [layer convertTime:CACurrentMediaTime() fromLayer:nil] - pausedTime;
layer.beginTime = timeSincePause;
}
- (IBAction)pause:(id)sender {
[self pauseLayer:self.view.layer];
}
- (IBAction)resume:(id)sender {
[self resumeLayer:self.view.layer];
}
In my game.h file I have:
- (IBAction)pause:(id)sender;
- (IBAction)resume:(id)sender;
-(void)pauseLayer:(CALayer*)layer;
-(void)resumeLayer:(CALayer*)layer;
I need some help.

-[game pause:]: unrecognized selector sent to instance 0x845ece0
This means that you have an instance of the game class (which, btw, that class should be Game, not game, classes are capitalized) and something is calling the method pause: on that class, but there is no pause: method.
Given that the class is called Game (fixed) and pausing seems like a reasonable thing to do to a game, it is unlikely that this is an over-release problem. pause: seems like it is something that you might have a button hooked up to in interface builder.
Did you, perchance, rename the pause: method to something else (pauseGame:?) and not fix the connection in IB?
And that pause: implementation is inside the #implementation Game scope? If so, trying cleaning the project and rebuilding as there may be a dependency issue. If not, then that is your problem.
If the build from clean thing doesn't work, then there is some detail missing. Since building from clean didn't work, you'll have to post more details. Show the declaration of the class, at least.

Related

"Unknown Class <MyClass> in my Interface builder error" but I don't have a MyClass

Here is the error I am receiving
2013-07-30 22:20:53.227 Matchismo[562:c07] Unknown class PlayingCardCollection in Interface Builder file.
2013-07-30 22:20:53.229 Matchismo[562:c07] -[UIView setSuit:]: unrecognized selector sent to instance 0x71433f0
2013-07-30 22:20:53.230 Matchismo[562:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView setSuit:]: unrecognized selector sent to instance 0x71433f0'
I don't have a class called "PlayingCardCollection" so I don't see how I could be receiving this error unless I named something wrong but I cannot find an error like that.
Here is some of my code
- (Deck *) createDeck
{
return [[PlayingCardDeck alloc] init];
}
- (NSUInteger) startingCardCount
{
return 20;
}
- (void)updateCell:(UICollectionViewCell *) cell usingCard:(Card *) card
{
if ([cell isKindOfClass:[PlayingCardCollectionViewCell class]]) {
PlayingCardView* playingCardView = ((PlayingCardCollectionViewCell *)cell).playingCardView;
if ([card isKindOfClass:[PlayingCard class]]) {
PlayingCard *playingCard = (PlayingCard *)card;
playingCardView.rank = playingCard.rank;
playingCardView.suit = playingCard.suit;
playingCardView.faceUp = playingCard.faceUp;
playingCardView.alpha = playingCard.isUnplayable ? 0.3 : 1.0;
}
}
}
And this is part of another file.
- (NSInteger) numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
return 1;
}
- (NSInteger) collectionView:(UICollectionView *)collectionView
numberOfItemsInSection:(NSInteger)section
{
return self.startingCardCount;
}
- (UICollectionViewCell *) collectionView:(UICollectionView *)collectionView
cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
UICollectionViewCell* cell = [collectionView dequeueReusableCellWithReuseIdentifier:#"PlayingCard" forIndexPath:indexPath];
Card* card = [self.game cardAtIndex:indexPath.item];
[self updateCell:cell usingCard:card];
return cell;
}
If anymore code is needed let me know. I have alot of files for this project but most weren't touched since my project had its last successful run. Thanks in advance!
Here's why your app is terminating:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView setSuit:]: unrecognized selector sent to instance 0x71433f0'
Looking more carefully at the reason, notice that it says:
'-[UIView setSuit:]: unrecognized selector sent to instance 0x71433f0'
The message is telling you that your app tried to send a setSuit: message to an instance of UIView. The UIView class doesn't declare a setSuit: method or a suit property, so ordinarily this won't work.
The problem may or may not be related to the first issue, where it looks as though you set the identity of an object (possibly a view) in a nib file to a class that you later deleted or renamed. Look at the identities of the objects in the nib file (using the Identity Inspector tab), and see if you can find PlayingCardCollection.
If so change it to something more appropriate. Chances are, that's the indirect cause of the runtime exception.
The error says it all.The class name set to some view in interface builder as PlayingCardCollection and the class does not exist
To find out one best option is to select the nib and right click on it, open it as source code where it shows the xml structure representation of your nib
Then search for PlayingCardCollection and find it.Find the nib with that content and you can find the view from that nib ,More study on the nib itself can sort out the view easily

NSInternalInconsistencyException PDF Viewer

I copied some good pdf viewing code from Julius Oklamcak. https://github.com/vfr/Viewer
It works great in his app when I do not modify it, but it gets messed up when I put it in my own app.
I removed the print, bookmark, and tile view buttons fyi.
The DONE button is not working.
Here is the error I am receiving:
2012-12-18 10:01:45.857 TeacherTableView4[1147:907] *** Assertion failure in -[ReaderViewController tappedInToolbar:doneButton:], (...my path to)/TeacherTableView4/ReaderViewController.m:844
2012-12-18 10:01:45.859 TeacherTableView4[1147:907] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Delegate must respond to -dismissReaderViewController:'
*** First throw call stack:
(0x371b52a3 0x3bd9497f 0x371b515d 0x3a2682af 0x40967 0x3c9f1 0x3676f0a5 0x3676f057 0x3676f035 0x3676e8eb 0x3676ede1 0x366975f1 0x36684801 0x3668411b 0x34a4f5a3 0x34a4f1d3 0x3718a173 0x3718a117 0x37188f99 0x370fbebd 0x370fbd49 0x34a4e2eb 0x366d82f9 0x414bd 0x36557b20)
libc++abi.dylib: terminate called throwing an exception
Here is the code:
- (void)tappedInToolbar:(ReaderMainToolbar *)toolbar doneButton:(UIButton *)button
{
#ifdef DEBUGX
NSLog(#"%s", __FUNCTION__);
#endif
#if (READER_STANDALONE == FALSE) // Option
[document saveReaderDocument]; // Save any ReaderDocument object changes
[[ReaderThumbQueue sharedInstance] cancelOperationsWithGUID:document.guid];
[[ReaderThumbCache sharedInstance] removeAllObjects]; // Empty the thumb cache
//COMMENTED OUT BY ME
//if (printInteraction != nil) [printInteraction dismissAnimated:NO]; // Dismiss
if ([delegate respondsToSelector:#selector(dismissReaderViewController:)] == YES)
{
[delegate dismissReaderViewController:self]; // Dismiss the ReaderViewController
}
else // We have a "Delegate must respond to -dismissReaderViewController: error"
{
NSAssert(NO, #"Delegate must respond to -dismissReaderViewController:");
}
#endif // end of READER_STANDALONE Option
}
I would really appreciate some help with this guys. Thanks!
I ran into the same problem using this PDF viewing code. I simply added this method
- (void)dismissReaderViewController:(ReaderViewController *) viewController
{
[self dismissModalViewControllerAnimated:YES];
}
to the .m file where I'm calling the - (IBAction)didClickOpen from.
This is mainly due to the fact that in ReaderViewController.m the delegate expects to see dismissReaderViewController declared in your implementation file. Otherwise, it will throw that error you're getting.
Note: Use [self dismissViewControllerAnimated:YES completion:nil]; for iOS6 or later since dismissModalViewControllerAnimated:YES was deprecated :-)

trouble debugging during runtime

I have written a some code for a drill down table app I have been making, but the app crashes only during runtime. Xcode doesn't give me any errors while building the app. The debugger outputs:
2012-10-18 10:58:26.513 second[474:c07] -[NavController setItems:]: unrecognized selector >sent to instance 0xc217a00
2012-10-18 10:58:26.515 second[474:c07] * Terminating app due to uncaught exception >'NSInvalidArgumentException', reason: '-[NavController setItems:]: unrecognized selector sent >to instance 0xc217a00'
* First throw call stack:
(0x14b8022 0xeb8cd6 0x14b9cbd 0x141eed0 0x141ecb2 0x3fbe 0xe2a1e 0x41401 0x41670 0x41836 >0xbfc9dd8 0x4872a 0x19596 0x1a274 0x29183 0x29c38 0x1d634 0x13a2ef5 0x148c195 0x13f0ff2 >0x13ef8da 0x13eed84 0x13eec9b 0x19c65 0x1b626 0x1d40 0x1cd9)
terminate called throwing an exception
I think I understand that the error lies in NavController.m where:
- (void)viewDidLoad
{
[super viewDidLoad];
NSString* path = [[NSBundle mainBundle] pathForResource:#"Data" ofType:#"plist"];
MasterViewController* root = (MasterViewController*)self.topViewController;
NSDictionary* thelist = [NSDictionary dictionaryWithContentsOfFile:path];
root.items = [thelist objectForKey:#"Items"];
root.navigationItem.title = [thelist objectForKey:#"name"];
}
btw, I made the array items like this: (nonatomic, retain) NSArray* items;
The app crashes, because of the following line:
root.items = [thelist objectForKey:#"Items"];
This line is just a shortcut for writing:
[root setItems:[thelist objectForKey:#"Items"]];
And the runtime complains that there is no method setItems: found. The reason why there is compile error is because you tell the compiler that root is of class MasterViewController, however, that is not true. At runtime the obj-c runtime finds out that root is in fact of class NavController and it seems like NavController has no setItems: method.
In other words, this line is wrong:
MasterViewController* root = (MasterViewController*)self.topViewController;
You lie about the class; self.topViewController returns an object that is of class NavController, yet you force the compiler to treat it as MasterViewController which will fail as soon as you call a method that is not found for NavController.
The problem is probably here:
MasterViewController* root = (MasterViewController*)self.topViewController;
self.topViewController is proably not an instance of MasterViewController, but a NavController instance and there you go.

uncaught exception 'NSInvalidArgumentException' ->Objective C

I was trying out a sample thread program from google and i am getting a runtime exception.
Is there any website that gives an example of how to use runloops along with threads.
I need to set two events and spawn a thread and to do another function parallely.
// Runner.m
#import "Runner.h"
#implementation Runner
- (void)rumMe:(id)ignored {
NSLog(#"Running with threads!!");
}
#end
// Runner.h
#interface Runner : NSObject
-(void)rumMe:(id)ignored;
#end
// Thread1.m
#import <Foundation/Foundation.h>
#import "Runner.h"
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
Runner* runner = [Runner new];
[NSThread detachNewThreadSelector:#selector(runMe:) toTarget:runner withObject:nil];
[pool drain];
return 0;
}
Runtime Exception:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '***
-[NSThread initWithTarget:selector:object:]: target does not implement selector (***
-[Runner runMe:])'
First part: you had a typo
// method declaration
rumMe: with an _m_
// call
runMe: with an _n_
Second part: your main function is returning and causing the program to exit before you have given the thread a chance to do anything. In this simple simple example, you could simply
sleep(2);
right after the call to detachNewThreadSelector:
In more complex cases, you might need to make a call to CFRunLoopRun(); on the main thread, or take other action to keep the second thread alive.
You have made a typo. The method in Runner is defined as rumMe, but in the main program you use runMe.

Fail to catch exception from proxy object under Xcode 3.2.3

I use HessianKit to communicate with server. In the situation of network or server down Hessian will throw exception, so I put every Hessian call in a #try ... #catch block. Everything worked fine until I upgraded Xcode from 3.2.2 to 3.2.3. I wrote the some testing code and found under Xcode 3.2.3, catch exception would be failed if the exception was thrown from a proxy object.
MyProxy.h:
#interface MyProxy : NSProxy {
}
#end
MyProxy.m:
#implementation MyProxy
- (id)init {
return self;
}
- (void)forwardInvocation:(NSInvocation *)invocation {
NSLog(#"Call method %#", NSStringFromSelector([invocation selector]));
[NSException raise:#"MyException" format:#"this is an exception"];
}
- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector {
.....
}
#end
Code using MyProxy:
#try {
MyProxy *p = [[MyProxy alloc] init];
[p doSomething];
[p release];
}
#catch (NSException * e) {
NSLog(#"%#", e);
}
When these code build under xcode 3.2.2, the exception can be catched correctly. But under xcode 3.2.3, the program terminated after output following on the console:
2010-09-08 21:09:29.877 BriefCase[34651:40b] Call method doSomgthing
2010-09-08 21:09:29.879 BriefCase[34651:40b] *** Terminating app due to uncaught exception 'MyException', reason: 'this is an exception'
2010-09-08 21:09:29.880 BriefCase[34651:40b] Stack: (
45955152,
47113004,
45692683,
45692522,
151932,
45426420,
45423090,
9352,
4417860,
4421967,
4447550,
4429047,
4461016,
53399932,
45234332,
45230248,
4420129,
4453234,
8812,
8666
)
terminate called after throwing an instance of 'NSException'
Program received signal: “SIGABRT”.
What can I do?
I filed a bug with Apple, and the reply is:
It has been determined that this is a known issue, which is currently being investigated by engineering. This issue has been filed in our bug database under the original Bug ID# 7995323.
Maybe your project/target/executable settings have been messed up?
Is the "Enable Objective-C Exceptions" box ticked for your configuration/target/etc?
If it is, maybe you should file a bug with Apple here.