简体   繁体   English

NSInvalidArgumentException isKindOfClass

[英]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. 我有一个我无法理解的问题,我正在使用一个库来使用Map Open Source Map( https://github.com/route-me/route-me ),该示例运行良好,我相信不要成为与代码相关的东西,我相信它是配置中的东西。 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: 我收到一个错误,指出UIView类没有方法markerManager:

2013-08-05 17:18:33.573 MapOffline[1310:907] 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' * 由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:'-[UIView markerManager]:无法识别的选择器发送到实例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. 注意:RMMarkerManager类继承自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. 我的.xib始终按需配置和引用了所有内容。

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. 如果使用情节提要,则需要将视图的“自定义类”(在身份检查器面板中)设置为RMMapView。 Otherwise the storyboard doesn't know which class to instantiate for your view. 否则,情节提要不会为您的视图实例化哪个类。

设置自定义类的示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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