Pointer points to a different object: (Unrecognized selector sent to instance) - iphone

I got this weird crash in my app, when i try to call this function on my object pageModel
[pageModel pageTitle] isEqualToString:#"some text"];
This is the debugger dump
-[__NSArrayM isEqualToString:]: unrecognized selector sent to instance 0x661de40
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM isEqualToString:]: unrecognized selector sent to instance 0x661de40'
and messing around with the debugger I found out some really strange behaviour
(gdb) po pageModel
<PXPage: 0x6622e20>
(gdb) po [pageModel pageTitle]
<__NSArrayM 0x661de40>(...
(gdb) po pageModel.pageTitle
<__NSArrayM 0x661de40>(...
It thinks it's a MutableArray but it's not. It should be a NSString...And some other time it was an UIImage and other time something else and so on.
Does anyone as a clue about what's going on here?
Thanks

This is a classic double release error. An object has been released too many times, the memory it occupies has been assigned to another object, so that other object is receiving messages meant for the old object.
You want set the NSZombieEnabled environment variable to YES in the scheme editor and run your application in the debugger. Google and/or stackoverflow search can help you find more information on this.

[pageModel pageTitle] is returns array. you are using NSString Class . it is the reason to crash. so check the data type of [pageModel pageTitle].

Related

UILabel error - [__NSCFNumber string]: unrecognized selector sent to instance

I am getting this error sort of randomly. It doesn't always happen but regardless, it doesn't make sense.
"[__NSCFNumber string]: unrecognized selector sent to instance"
shows up on this line:
_displayLabel.text = #"";
_displayLabel is an iVar of type UILabel and I am simply clearing the text from it here. Where is this NSCFNumber coming from? Is this an improper way of clearing the text from a UILabel?
Note: This is an ARC project.
UPDATE
I am getting a different error involving the same object in a different part of my code, again pretty randomly. Sometimes I see it, others I don't
-[NSConcreteMutableAttributedString string]: message sent to deallocated instance
I am seeing at this line
NSLog(#"displayLabel: %#", _displayLabel.text);
I'll reiterate that this is an ARC project and I have no release messages anywhere in my code. Could it be that ARC has inserted them poorly?

Random crashes from Cocos2d actions

I'm getting a few inconsistent crashes whenever some CCAction is being applied to a sprite.
Ex: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[CCScaleBy actionWithDuration:scale:]: unrecognized selector sent to class 0x1860a4'
I get the same thing with CCBlink sometimes too. The actions are being called from inside a scheduler (using a BOOL flag to make sure they only run once).
Any ideas on why I'm getting these kind of errors? Its very inconsistent. Thanks
You've got NSInvalidArgumentException. Make sure that you pass needed values to the method. For example, that you don't try pass BOOL value when method waits for float, etc.

Ugly XCode Error: It thinks my NSArray is a UIImageView?

Whenever I call the code below,
BOOL currentState = [[allGroupThreeArray objectAtIndex:indexNumber] getState];
I get the the console errors below:
-[UIImageView objectAtIndex:]: unrecognized selector sent to instance 0x1f574d50
and
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImageView objectAtIndex:]: unrecognized selector sent to instance 0x1f574d50'
I have no idea why it says "UIImageView objectAtIndex" because allGroupThreeArray is an NSArray which is defined above the #implementation by the code below
static NSArray *selectedGroupThreeArray;
selectedGroupThreeArray is an array of instances of my class "ItemInstance" and "getState" is a public method in that class that returns a bool.
I have spent hours on this and have absolutely no idea what the issue is. Any help is greatly appreciated!
EDIT: indexNumber is defined by the code below
int indexNumber = itemNumber-300-1;
where itemNumber is a parameter that is sent to the method that all of this is occurring in.
Errors like this are usually signs of memory issues. Your array is probably released, but not set to nil before you try to call objectAtIndex:.

Iphone 'NSInvalidArgumentException', reason: '-[__NSCFSet setPolicyNumber:]

Hi i am a newbie to iPHone development and I am getting this error that states that the setter method cannot be found for a string variable despite that variable being declared with the #property and #synthesize declarations. The variable is contained within a seperate object to the class which I am attempting to set the value.
Any help would be appreciated.
here is the code relating to the error.
[reg setPolicyNumber:self.policyNoField.text];
[reg printSummaryToConsole];
debugger says that
-[__NSCFSet setPolicyNumber:]: unrecognized selector sent to instance 0x643fd80
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFSet setPolicyNumber:]: unrecognized selector sent to instance 0x643fd80'
I have allocated an initialized the Registration class (reg) in this class and I have the PolicyNumber created and synthesized in the registration class also. yet I am still getting this error.
Any help would be appreciated.
reg is a reference to an instance of NSCFSet.
Most likely, you failed to retain whatever reg was supposed to refer to in the first place and, coincidentally, an NSCFSet happened to be allocated where the old object was.
Use Build and Analyze, then use zombie detection if that doesn't identify the problem.

Unrecognized selector sent to instance - on setter method

Every time try to set the value of any variable in my model object, I receive 'Unrecognized selector sent to instance' error, and the app crashes. The ivars have been synthesized and they are not readonly. I have checked to see the values set are of the right type.
I am not sure if it has to do with some connection in IB, which I have checked an re-checked.
One extra bit of information: I started developing in an earlier version of Xcode, and the same piece of code used to work on that version.
Here is the exact error message:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFString setDistance:]: unrecognized selector sent to instance 0x380ce50'
2009-11-10 15:10:58.113 CabMeter[7432:207] Stack: (
29303899,
2457931593,
29685819,
29255286,
29107906,
11415,
3140002,
3149770,
3199319,
3236748,
3170686,
3230561,
3179329,
12452,
3918761,
3933474,
4979284,
4987529,
3990121,
2838067,
2746396,
2773173,
37400273,
29088640,
29084744,
37394317,
37394514,
2777091,
9208,
9062
)
The ivars have been synthesized and they are not readonly.
I think you're confusing instance variables with properties. Properties are what you normally synthesize and/or make read-only, and they are usually, but not necessarily, backed by instance variables.
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFString setDistance:]: unrecognized selector sent to instance 0x380ce50'
This is why you should read the error message.
You're not sending your setDistance: message to your model object—you're sending it to a string. Most likely, you didn't retain the model object like you should have, and a string got allocated shortly thereafter with the same address.
Review the memory management rules and look to find where you're not following them. If all of your properties are set correctly, make sure you're actually using them: A common mistake is to assign directly to the ivar:
myModel = [[[MyModel alloc] init] autorelease]
instead of going through the property:
self.myModel = [[[MyModel alloc] init] autorelease]
or
[self setMyModel:[[[MyModel alloc] init] autorelease]]
'Unrecognized selector sent to instance' sounds like you have a delegate the defines a selector for a method that doesn't exist.
Do you have a #selector(methodName) anywhere in your code?
In the stack trace, what is the last of your code that is called before the exception is thrown?
If it's on the setter method, could we see how you declare the instance variable and how you synthesize it?