By n179911

2014-09-15 17:54:59 8 Comments

I am creating a custom table cell view for my table view. After I connect an image view of custom cell (in storyboard) to my code in swift, I get the following error.

[UITableViewCellContentView image]: unrecognized selector sent to instance 0x7fb4fad7fd20'
*** First throw call stack:
    0   CoreFoundation                      0x000000010ccbb3f5 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010e7e9bb7 objc_exception_throw + 45
    2   CoreFoundation                      0x000000010ccc250d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x000000010cc1a7fc ___forwarding___ + 988
    4   CoreFoundation                      0x000000010cc1a398 _CF_forwarding_prep_0 + 120
    5   UIKit                               0x000000010d7d8881 -[UITableViewCell _marginWidth] + 151
    6   UIKit                               0x000000010d7ca23d -[UITableViewCell _separatorFrame] + 70
    7   UIKit                               0x000000010d7ca6fa -[UITableViewCell _updateSeparatorContent] + 360
    8   UIKit                               0x000000010d7d4e85 -[UITableViewCell _setSectionLocation:animated:forceBackgroundSetup:] + 1174
    9   UIKit                               0x000000010d634ea8 __53-[UITableView _configureCellForDisplay:forIndexPath:]_block_invoke + 1822
    10  UIKit                               0x000000010d5b5eae +[UIView(Animation) performWithoutAnimation:] + 65
    11  UIKit                               0x000000010d63477b -[UITableView _configureCellForDisplay:forIndexPath:] + 312
    12  UIKit                               0x000000010d63bcec -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 533
    13  UIKit                               0x000000010d61b7f1 -[UITableView _updateVisibleCellsNow:isRecursive:] + 2846
    14  UIKit                               0x000000010d63165c -[UITableView layoutSubviews] + 213
    15  UIKit                               0x000000010d5be199 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 521
    16  QuartzCore                          0x00000001114b6f98 -[CALayer layoutSublayers] + 150
    17  QuartzCore                          0x00000001114abbbe _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
    18  QuartzCore                          0x00000001114aba2e _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
    19  QuartzCore                          0x0000000111419ade _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242
    20  QuartzCore                          0x000000011141abea _ZN2CA11Transaction6commitEv + 390
    21  QuartzCore                          0x000000011141b255 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 89
    22  CoreFoundation                      0x000000010cbf0347 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
    23  CoreFoundation                      0x000000010cbf02a0 __CFRunLoopDoObservers + 368
    24  CoreFoundation                      0x000000010cbe60d3 __CFRunLoopRun + 1123
    25  CoreFoundation                      0x000000010cbe5a06 CFRunLoopRunSpecific + 470
    26  GraphicsServices                    0x0000000110daa9f0 GSEventRunModal + 161
    27  UIKit                               0x000000010d545550 UIApplicationMain + 1282
    28  TestWork                          0x000000010caa432e top_level_code + 78
    29  TestWork                          0x000000010caa436a main + 42
    30  libdyld.dylib                       0x000000010efc3145 start + 1
    31  ???                                 0x0000000000000001 0x0 + 1

Can you please tell me how to resolve this error?

Thank you.

I add an exception breakpoint in my project.

This is the line where it breaks.

  override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell = self.tableView.dequeueReusableCellWithIdentifier(kCellIdentifier) as ItemTableViewCell  <---------------

But I don't use 'image' in my code.


@Saranjith 2017-04-06 17:46:35

Swift 5.0

You can use Introspection to find out whether object responds to a particular selector or not..

let canWork = yourObject.respondsToSelector(Selector("image"))   // true

Only if it is true that code will work.. otherwise it will crash for sure

@Rohit Parsana 2016-11-30 09:58:34

You have to pass indexPath to declare object of tableview cell.

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath)

    return cell

@Vatsal K 2016-04-13 06:34:34

You can easily track such crashes using Exception Breakpoints.

Open the Breakpoint Navigator and add the

enter image description here

Once you add the Exception Breakpoint, option will be open to choose the Exception.

enter image description here

Select Objective-C.

Run the code and crash the application, breakpoint will stop you to the point where the code is crashing.

@Daniel Springer 2020-03-12 22:59:47

It happens on AppDelegate line 1. Now what? :(

@Vatsal K 2020-03-13 19:29:15

Can you show some of your code written in AppDelegate? Where it's pausing the breakpoint. And also the logs as well.

@Daniel Springer 2020-03-13 19:40:58

it pauses on line 1, where app delegate is declared

@Vatsal K 2020-03-13 21:44:42

There are some cases where it pauses, because of some frameworks, But don't worry about that you might need to press continue button for 3-4 times to run the application.

@Vatsal K 2020-03-16 14:29:56

That's not an error in such case, Some old frameworks are causing this kind of problem. Try by updating your old frameworks to new/updated ones. That should resolve the problem.

@Vatsal K 2020-03-16 21:24:51

I can not diagnose error/warnings without seeing the code. If you can show me suspicious code, then I could help you.

@Yogesh shelke 2016-03-03 05:09:12

You can use the following code to declare the variable:

let noteListTableViewCellobject = "NoteListTableViewCell";` `// Note listTablecell create custom cell`

func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {

    var cell:NoteListTableViewCell? = tableView.dequeueReusableCellWithIdentifier(noteListTableViewCellobject) as? NoteListTableViewCell

    if (cell == nil) {
        let nib:Array = NSBundle.mainBundle().loadNibNamed("NoteListTableViewCell", owner: self, options: nil)
        cell = nib[0] as? NoteListTableViewCell

@ABC 2015-07-24 17:34:43

In these scenarios I've found it helpful to look at two things

  1. The call-stack
  2. The local variables (and their types) at each stack frame

When I've had this error, it's usually because I sent a message to an instance of Type A, when I was expecting Type B.

In this specific scenario, you may not be satisfying a requirement of a parent class (given your instance of ItemTableViewCell most likely inherits).

Can you maybe show us the code for your ItemTableViewCell class?

@Razvan 2015-02-20 16:12:11

I had the same problem, and this worked for me:

Override the isEqual in your SKScene:

- (BOOL)isEqual:(id)other {

    if (![other isMemberOfClass:[SKScene class]]) {
        return false;
    return [super isEqual:other];

@Bryan 2015-01-18 14:43:17

Another possible reason is that the original object was destroyed and then another object was allocated at the same memory address. Then your code sends the message, thinking it still has a pointer to the old object, and Objective-C throws an exception because the new object doesn't understand that message.

To diagnose this problem, run the Profiler with 'Zombies' detection.

@Hot Licks 2014-12-23 18:28:43

The critical first step is to analyze the error message:

[UITableViewCellContentView image]: unrecognized selector sent to instance

This tells you that the "message" image was "sent" to an object of class UITableViewCellContentView. (In other words, an attempt was made to call the method image on an object of class UITableViewCellContentView.)

The first thing to ask is "Does this make any sense at all?" It may be that the named class has an Image method, but not an image method, and so the wrong method name was used on the call. Or it may be that the named method is someMethod:someParm:, but the class implements someMethod:someParm:anotherParm:, meaning that a parameter was omitted on the call.

Most often, though, the named class does not have any method even vaguely resembling the named method, meaning that somehow a pointer to the wrong object was used in the failing call.

For instance, one might do:

NSArray* myArray = [myDictionary objectForKey:@"values"];
NSString* myString = [myArray objectAtIndex:5];

And get an error along the lines of:

[__NSDictionaryI objectAtIndex:] unrecognized selector sent to instance

because the object retrieved from myDictionary was, in fact, an NSDictionary, not the NSArray that was expected.

Most confusing, unfortunately, is when this sort of error occurs deep in UI system code rather than in your own code. This can happen when you somehow passed the wrong object to a system interface, or perhaps configured the wrong class in Interface Builder or wherever.

@dbart 2014-09-15 18:04:24

Try setting a symbolic breakpoint on -[NSObject(NSObject) doesNotRecognizeSelector:]. Just click [+] in the bottom left corner of the Breakpoint Navigator to add a breakpoint. Then click 'Add Symbolic Breakpoint'. Reproducing your crash now should give you a better idea where in your code the issue occurs.

enter image description here

@rebello95 2014-09-15 18:26:50

Could also just add an exception breakpoint.

@AntiMoron 2016-09-21 08:48:31

Saved my day, bro.

@Mohd Sadham 2016-10-22 13:37:49

Thank you it is so usefully

Related Questions

Sponsored Content

2 Answered Questions

3 Answered Questions

[SOLVED] Xib file as a Custom TableView Cell crashes

4 Answered Questions

[SOLVED] Download JSON async crash

1 Answered Questions

[SOLVED] UICollectionView sizeForItemAt IndexPath

1 Answered Questions

[SOLVED] Delegate error in table view cell

1 Answered Questions

1 Answered Questions

[SOLVED] Download data and display it

1 Answered Questions

[SOLVED] PFQueryTableViewController sections

Sponsored Content