I see this in my log:
2011-08-05 17:29:45.994 Test[3834:707] -[MyClass copyWithZone:]: unrecognized selector sent to instance 0x102218b90
what usable information does this line contain to track down exact point where unrecognized selector is sent? My understanding is that 3834 is PID, but I don't know what is 707 value. Also, is unrecognized selector copyWithZone: or is that place where the problem occured? (I don't override that method anywhere though)
copyWithZone: is the unrecognized selector. It was being sent to an instance of MyClass. My guess is you tried to use this object as a key in an NSDictionary? You can only use objects which conform to the NSCopying protocol as keys.
This looks like you failed to make MyClass a subclass of NSObject. (sorry, #jtbandes is right. It's not NSObject, it's NSCopying.)
707 is the thread identifier.
To track down where this happened, in the Run menu of Xcode 3, select "Stop on Objective C Exceptions." In Xcode 4, use an exception breakpoint.
Related
I'm trying to send some data from a swift file to an objective-c file. I have all the bridging headers and whatnot configured, such that when I pass a string, it can be used by the objective-c file. However, I would really like to pass an NSArray, and when I do this, I get a whole slew of errors starting with
[Swift._NSSwiftArrayImpl length]: unrecognized selector sent to instance 0x6000000363a0
I saw Array element cannot be bridged to Objective-C but solutions on that page, which were switching the Array to an NSArray in swift, and making all the objects in the array AnyObjects, did not work; besides, the error I got is different from the error on the aforementioned question. This is my condensed code:
Swift:
var myNSArray = ["foo","bar"]
objectiveCClassInstance.arrayPassFunction(myNSArray)
.h:
- (void)arrayPassFunction:(NSArray*)myObjectiveCNSArray;
.m:
- (void)arrayPassFunction:(NSArray*)myObjectiveCNSArray{
NSLog(myObjectiveCNSArray);
}
Your call to NSLog is incorrect. The first parameter of NSLog is the format string. You meant:
NSLog(#"%#", myObjectiveCNSArray);
I'm surprised you didn't get a warning about this.
For some reason I'm having a very difficult time wiring my NSToolbarItem to an IBAction.
I'm using an NSWindowController with its own XIB. The NSToolbar is dropped into the XIB, and I added the NSToolbarItem without issue. This whole NSWindowController is created by a master NSViewController when an image is clicked.
The problem lies with the new button not sending. I unchecked "Autovalidates" and checked "Selectable" so that I could actually click the button.
However when pressed, I receive "unrecognized selector sent to instance".
I've wired this several times over through the XIB interface to make sure I wasn't messing up.
What's going on? Thank you.
Full error:
-[__NSCFType buttonPressed:]: unrecognized selector sent to instance 0x101915010
The delegate class does not know the selector you've wired. Either your delegate is wrong or you've got a typing error in your method.
Check the signature of the Method you've declared in your headerfile vs. its implementation in the class file. Perhaps you forgot to declare a parameter.
edit:
the class type where the selector is called looked weird, so I googled __nscftype unrecognized selector. here are some suggestions, it seems like your delegate is already disposed :
http://imlocation.wordpress.com/2007/09/13/strange-objects-nscftype-indicate-memory-management-bugs/
[__NSCFType searchKeyword:]: unrecognized selector sent to instance 0x6d8eb80
Warning: complete newbie Xcode question.
In MainViewController.h I have the following line:
IBOutlet WorkItem *m_WIone;
I have created a class called WorkItem which is inherited from UILabel. The line above is so that I can use m_WIone (which will eventually become an array of such objects) as a member variable throughout MainViewController.
I have tried various ways to call WorkItem methods and finally settled on:
[m_WIone Reset];
where Reset is a WorkItem method. The method is declared in WorkItem.h as:
-(void) Reset;
and in WorkItem.m as:
-(void) Reset {}
With or without contents in this method, the app always crashes with:
Thread 1: Program received signal: "SIGABRT".
In the logging, I read:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UILabel Reset]: unrecognized selector sent to instance 0x6a5f9f0'
How can I solve this? Am I even declaring this member variable correctly? (Despite trawling through StackOverflow, I cannot find the solution.)
Did you specify your custom class for the NIB? It seems like you want a widget in XCode's Interface Builder to use your custom class. Only the default class (UILabel) would be instantiated instead of your custom class.
Click on the UILabel you're using as the outlet and change the class (the screenshot here is for UITableView, but it should work the same for UILabel).
With that being said, there are alternatives to what you're trying to do. Instead of just using UILabel (which you eventually plan to make an array of them). Why not use a UITableView and customize cells to what you see fit (since UITableViews optimal for displaying lists of items)?
My iphone app crashes with the following error message:
2010-07-26 16:27:30.402 Nav[814:207]
* -[UITextField isNaturallyRTL]: unrecognized selector sent to instance
0x3947fe0 2010-07-26 16:27:30.403
Nav[814:207] * Terminating app due
to uncaught exception
'NSInvalidArgumentException', reason:
'*** -[UITextField isNaturallyRTL]:
unrecognized selector sent to instance
0x3947fe0'
I can't find the text isNaturally RTL in my program. Any ideas on how to find the bug?
It seems that isNaturallyRTL is an (undocumented) NSString method. At least NSString responds to it.
This may mean that you assign a UITextField to some variable, where you should put in an NSString instead.
BTW: 0x3947fe0 is the pointer to the UITextField that should be an NSString, so if you're totally lost, try to find out which UITextField has that address (e.g. by a dumb NSLog("tf X: 0x%x",tfx);)
I found the problem. It was in this line of code:
[tempValues setObject:textFieldBeingEdited forKey:tagAsNum];
I changed it to the following:
[tempValues setObject:textFieldBeingEdited.text forKey:tagAsNum];
and that's what fixed it.
It's because your UITextField object is somehow assigned to a variable/property which is not supposed to be a UITextField.
It can happen in many different ways.
You might have connected the IB outlet incorrectly. Check your nib in the Interface Builder to see your UITextField is not connected to something strange.
You might have just assigned an UITextField to a variable of a different type. In that case, the compiler should have given you a warning. Correct your code and remove all the warnings.
You might have not correctly done retain/release. Do "build and analyze", and remove all warnings.
I have a class that subclasses NSMutableArray.
I init it using:
MyClass class = [MyClass arrayWithContentsOfFile:path];
When i try to access any of my subclass methods the app crashes with this error:
-[NSCFArray loadCards]: unrecognized selector sent to instance 0x454a30
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[NSCFArray > mymethod]: unrecognized selector sent to instance 0x454a30'
app[32259:20b] Stack: (
2524995915,
I am suspecting this happens because arrayWithContentsOfFile:path returns NSArray and not "MyClass" so it can't response to my selector.
Any ideas?
NSArray is a class cluster. To create a new subclass within a class cluster, you must implement its primitive methods.
If what you want is to inherit the behavior of an array, it's usually a better idea to do that with a has-a relationship, rather than an is-a. That is, to write a class that has an NSArray instance variable, and simply forwards the relevant messages to it.
Or, if you want to add new behavior to NSArray, you should do that by adding methods directly to the NSArray class in a category.
Essentially, you basically only want to subclass if you want to provide an NSArray interface for a different storage mechanism, and for that job you'd need to implement the primitive methods anyway.