-1

I am getting the error

unrecognized selector sent to instance

Which ok should have something to do with

    let nibName=UINib(nibName: "bankCollectionViewCell", bundle:nil)

    self.bankCollection.registerNib(nibName,  forCellWithReuseIdentifier: "selectBank")


    let cell = bankCollection.dequeueReusableCellWithReuseIdentifier("selectBank", forIndexPath: indexPath) as! bankCollectionViewCell



let cell = 
  bankCollection.dequeueReusableCellWithReuseIdentifier("selectBank", 
  forIndexPath: indexPath) as! bankCollectionViewCell

Which - if it was - then I could perhaps deal with it. But- the problem does not exist when I run the App in the simulator and choose iphone5. It only happens when I choose iphone 6 or ipad. So the cell is named ok.

This leads me to think that the code itself is fine - which then leads me to think - what else could be wrong. I cannot fix code that is not wrong - and yet it doesnt work.

The line of code that is highlit after the error is the above one -

the message given is:

[__NSCFString zIndex]: unrecognized selector sent to instance 0x7fd760cc4740

From the trace

could not dequeue a view of kind: %@ with identifier %@ - must register a nib or a class for the identifier or connect a prototype cell in a storyboard"

Which AHA you say the nib has to be registered - and yet it is (if I use the iphone 5 simulator) And no I dont have any special code to select different devices.

And again - this code works in the iphone5 simulator but not 6.

further to the above I have found that if I edit the story board and make the cell size larger - then I have some success. However I am now facing the issue that as soon as I scroll - the App crashes - same sort of error.

Reading around - I am not sure what is wrong - some sort of memory allocation it seems - but I am not sure what or how

techguy
  • 47
  • 2
  • 9
  • 1
    What is the exception message? What selector was sent? To what class of object was it sent? Which line of code caused it? – Paulw11 Aug 10 '15 at 21:14
  • Have you tried enabling zombies? What version of Xcode/swift are you using? – Paulw11 Aug 10 '15 at 22:22
  • I am using Xcode 6.4. I have enabled zombies but do not see anything appreciably different - same error – techguy Aug 10 '15 at 22:55
  • Please see this answer, this is how I have solved same problem: https://stackoverflow.com/a/54329180/7987502 – Egzon P. Jan 23 '19 at 14:16

1 Answers1

0

Your problem is there:

let nibName=UINib(nibName: "bankCollectionViewCell", bundle:nil)

I think your XIB name is BankCollectionViewCell, with capital letter. And according to documentation, simulator isn't case sensitive, but real device is. So solution for you is put correct nibName:

let nibName=UINib(nibName: "BankCollectionViewCell", bundle:nil)

Vitalii Gozhenko
  • 9,220
  • 2
  • 48
  • 66
  • I would like for that to be right - but sadly the Nib name is bankCollectionViewCell. Furthermore - in case I was not clear - this runs in the simulator when I chose iphone 5 - it works fine. When I choose Iphone 6 in the simulator - I get the error. So (to my untrained eye) its not a simple "got the name wrong" issue. I wish it were – techguy Aug 10 '15 at 22:14
  • Hum... I had problems like this previous, and sometimes reset simulator, and clear project derived data helps me (goto Xcode preferences, Locations tab, goto Derived data folder, and remove folder, which begins with your project name). Also after that you can do project clean: menu Product->Clean – Vitalii Gozhenko Aug 10 '15 at 22:19
  • Again - I would like that to have worked - and it sounded so good!! But the problem persists. It has me stumped - as if it just always did not work that would be easier. Note it also works in iphone4 on the simulator – techguy Aug 10 '15 at 22:39
  • Try to change cell nib name and cell class name. Maybe it helps – Vitalii Gozhenko Aug 10 '15 at 23:13