How to debug unrecognized selector sent to instance
This error:
'NSInvalidArgumentException', reason: '-[Merchant merchantId]: unrecognized selector sent to instance 0x7fad19529490'.
Means that you have an object at location 0x7fad19529490
and you tried to call "merchantId" on it. That object does not respond to merchantId
.
So, look very carefully at the definition of Merchant. Did you get the spelling of merchantId
right in fieldMappings
? Is it merchantID
with a capital D?
If you are sure that merchant has a property named merchantId
exactly, then, the next likely thing is that the object at 0x7fad19529490
is not a Merchant.
The easiest thing to do is to add an exception breakpoint (use the +) at the bottom of the breakpoint navigator. When this exception happens, grab the pointer address from the error (it might be different each time) and see what it is in the debugger. To do that, at the (lldb) prompt, type:
po (NSObject*)(0x7fad19529490)
but use the address from the error. If it's a Merchant, I expect it to say something like:
<Merchant: 0x7fad19529490>
Or, if you have overridden description
, it will be the output of that.
unrecognized selector sent to instance error in Objective-C
It looks like you're not memory managing the view controller properly and it is being deallocated at some point - which causes the numberButtonClicked:
method to be sent to another object that is now occupying the memory that the view controller was previously occupying...
Make sure you're properly retaining/releasing your view controller.
[Label compare:]: unrecognized selector sent to instance
NSSortDescriptor(keyPath: \Sample.label, ascending: true)
=>
NSSortDescriptor(keyPath: \Sample.label.name, ascending: true)
In the first one, you are trying to sort Sample
on its label
(Label
) property.
So a some point, it will do [someLabelInstance compare:someOtherLabelInstance]
to know if which one needs to be put before the other one. But, Label
doesn't have an instance method compare()
, that's why you get the error.
You want in fact sort on the name
property of that label
. Property which is a String
(implicit by reading your code), and is "sortable" (implements compare()
).
unrecognized selector sent to instance
I guess that you are incorrectly linking them.
you need to add UITableViewDelegate
to your super Class
and in the viewDidLoad
self.tableView.delegate = self
self.tableView.dataSource = self
make sure you are linking the tableView as follows
.
you should have this!
Related Topics
Ios Simple Tcp Connection Example
Determine Device (Iphone, Ipod Touch) With Ios
How to Safely Delete Contents of Xcode Derived Data Folder
Can't Use Swift Classes Inside Objective-C
Firebase Query - Find Item With Child That Contains String
Loaded Nib But the 'View' Outlet Was Not Set
How Disable Copy, Cut, Select, Select All in Uitextview
How to Enable File Sharing For My App
How to Create a Custom Uiactivity in Ios
Why Does Viewwillappear Not Get Called When an App Comes Back from the Background
React Native App Crashes on Launch Screen on Device
How to Determine the Current Iphone/Device Model
How to Return Value from Alamofire
How to Rotate a Uiimage 90 Degrees
Generate .Pem File Used to Set Up Apple Push Notifications
Iphone 6 Plus Resolution Confusion: Xcode or Apple'S Website? For Development
How to Have Stored Properties in Swift, the Same Way I Had on Objective-C