NSInvalidArgumentException isKindOfClass

一曲冷凌霜 提交于 2019-12-25 11:14:54

问题


I have a problem that I could not understand, I'm using a library for the use of Map Open Source Map (https://github.com/route-me/route-me), the example works perfectly, and I believe not to be something connected to the code , I believe it is something in the configuration. Well what happens is that if I make the following call:

RMMarkerManager *markerManager = [mapView markerManager];

I get an error that says the UIView class does not have the method markerManager:

2013-08-05 17:18:33.573 MapOffline[1310:907] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView markerManager]: unrecognized selector sent to instance 0x1d88fbb0'*

No entanto, se eu adicionar a validação, o código funciona perfeitamente:

if ([mapView isKindOfClass:[RMMapView class]]) {
    RMMarkerManager *markerManager = [mapView markerManager];
}

The sample project does not have this validation and works, someone could tell me what can be? It is not good practice validate whenever you use methods of this class.

Note: The RMMarkerManager class inherits from UIView.


What happened in my case was that I was not making reference to some images that were being used by the project the in example. I honestly do not know what that has to do one thing with another, more after adding the images in the project, everything worked perfectly. I guarantee that I have made no other changes.

My .xib always configured and referenced everything as it should.

I'm not understanding why this, more this was my solution.

:-/


回答1:


If you used a storyboard then you need to set the "custom class" (in the identity inspector panel) of your view to be RMMapView. Otherwise the storyboard doesn't know which class to instantiate for your view.



来源:https://stackoverflow.com/questions/18067321/nsinvalidargumentexception-iskindofclass

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!