-[NSNull _isNaturallyRTL]: unrecognized selector sent to instance 0x20dfcd8 - iphone

i know, this is strange but,
-[NSNull _isNaturallyRTL]: unrecognized selector sent to instance 0x20dfcd8
i found the problem, while using fb graphAPI.
It was in this line of code:
[tempValues setObject:textFieldBeingEdited forKey:tagAsNum];
I want to change it to
[tempValues setObject:textFieldBeingEdited.text forKey:tagAsNum];
but i dont find this anywhere in my code.
Do anybody hv idea, in which class it can be.

I would say that textFieldBeingEdited is either nil or NSNull. I'm not certain what tempValues is, so I don't know if its setObject:forKey: automatically converts nil to NSNull.

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?

Xcode 4.3.3 -[__NSArrayM length]: unrecognized selector sent to instance 0x6b6dc60

I have an iPhone application where i download information from the internet and put it into an NSString. It works fine, until i download large files and put it into that one string, then i get the error
-[__NSArrayM length]: unrecognized selector sent to instance 0x6b6dc60
At one point i was getting a EXC_BAD_ACCESS error, but now that's not showing up. I'm guessing that it is a memory problem but i dont know how to fix it. Is there a limit to how large a string variable can be? Any suggestions? I should also mention that the error sometimes doesn't show up, but most of the time it does. Thanks in advance.
Well, it looks like you're trying to get the length of the array by calling a method called length on an array, but to get the length of an array you use the count method like this for example:
NSInteger numberOfElements = [someArray count];
Hope this helps!
P.S. The length method exists but it is used on NSString objects to get the number of characters in the string.
----UPDATE-----
From Ray Wenderlich's "My App Crashed, Now What?" tutorial:
The error message “unrecognized selector sent to instance XXX” means that the app is trying to call a method that doesn’t exist.
So somewhere in your code, you are calling the length method on an object of type NSArray.
You are actually calling the length method on an object of type NSMutableArray, and you know that from the error because __NSArrayM represents an NSMutableArray object; a regular NSArray object would be represented as __NSArrayI (the suffixed "M" stands for "mutable" while the suffixed "I" stands for "immutable").
I even found a very similar question that has a very similar answer to mine:
NSArrayM length : unrecognized selector sent to instance
Heh, I had this before. Somewhere you're doing this: [array length]; but arrays use "count", not "length".
This is happening because you are trying to cast NSMutableArray to NSString, you can remove this error simply by using objectAtIndex:0.
when we use objectAtIndex:0 ,it returns object and in your case that object is your NSString & hence removes error.
e.g.
self.quizTextView.text=[questionTexts objectAtIndex:0];
Try turning on zombies to get a better error message. It's probably something being deallocated before you expect. You can also try running your app in the "Allocations" or "Leaks" instrument to track down why your objects are being released before you expect.

How to read 'unrecognized selector' error logs in obj-c / iphone apps

i've got the following crash log error in my app:
-[NSNull length]: unrecognized selector sent to instance 0x194adc8
How do i read this? Does it mean that:
I sent a 'length' message to a 'NSNull' object?
The 'length' method in the 'NSNull' class crashed when trying to call a selector on another class?
Also, if it is the former option, how can i get the stack trace to see which function caused this crash? That top line is the only error in my log.
Thanks
Door 1
NSNull does not respond to length
You can check the documentation for NSNull to see that this is the case.
Without having an idea of what your code base is doing I am not sure where to look, you must be calling [NSNull null]; at some point to get the NSNull object or you are using a framework somewhere that returns this.
It means you sent 'length' to NSNull and NSNull doesn't have a 'length' function.
Turning on NSZombies might help you (it keeps deallocated objects around so it can tell you which object you tried to access) but I think in this case you probably set an object to NSNull at some point (or it was returned from a function).
Anyway to turn on NSZombies, go to Project > Edit Active Executable > Arguments tab > Then add a variable called NSZombieEnabled and set the value to YES. Make sure you turn it off when you're done though because it can cause memory issues.
It means that you are using a Length method for calculating the string length
Like
If([strText Length]>0)
{
//do something here----
}
else
{
//Do somethig here--
}
So in above case- strText is NSNull then definitely a crash will accure and GDB will show a message like:
[NSNull length]: unrecognized selector sent to instance
As above told already Null don't have Length method.
For rescue:
check first:
if ((NSNull *)strText == [NSNull null])
{
return strText=#"";
}
This will prevent for crash for NSNULL
Zombies won't help in this case. As Paul.s said, NSNull is a valid object. You should get the stack trace when the app stops. Do you have the debugger pane open? Make sure it is. I'm pretty sure Xcode 4 always stops on exceptions with the stack trace. If for some reason you're still not seeing it, if you are at the (gdb) prompt, you can type 'bt' (backtrace) to get the trace.
Because you are coparing NSNull class to lenth
check before fo that
if ([NSString *str isKindOfClass:[NSNull null]]){
str=#"";
}
then check length for the str.
it works!thx

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

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].

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?