简体   繁体   中英

NSInvalidArgumentException isKindOfClass

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.

:-/

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.

设置自定义类的示例

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM