简体   繁体   English

不兼容的Objective-C类型-尝试传递NSURL

[英]Incompatible Objective-C types - trying to pass NSURL

I have this line of code, where I'm trying to assign a URL from an annotation on a custom MKAnnotation to a UIWebView controller. 我有这行代码,在这里我试图将来自自定义MKAnnotation上的注释的URL分配给UIWebView控制器。

webViewController.webViewURL = annotation.url;

Basically, I have an NSURL stored in annotation.url, and am trying to send this NSURL to webViewController.webViewURL. 基本上,我有一个NSURL存储在注解.url中,并且正在尝试将此NSURL发送到webViewController.webViewURL。

When I try running this code, I get "EXC_BAD_ACCESS" in the console. 尝试运行此代码时,控制台中显示“ EXC_BAD_ACCESS”。 Running the Allocations Instrument (with NSZombiesEnabled) didn't show any zombies... I can't understand why this is happening, especially since, if I change the line to use 'URLWithString...' and build a new NSURL... 运行分配工具(使用NSZombiesEnabled)没有显示任何僵尸……我不明白为什么会这样,尤其是因为如果我将行更改为使用“ URLWithString ...”并构建新的NSURL。 。

webViewController.webViewURL = [NSURL URLWithString:annotation.url];

...it works without a problem, though I get the warning: Incompatible Objective-C types 'struct NSURL *', expected 'struct NSString *' when passing argument 1 of 'URLWithString:' from distinct Objective-C type ...它没有问题,但是我得到警告: Incompatible Objective-C types 'struct NSURL *', expected 'struct NSString *' when passing argument 1 of 'URLWithString:' from distinct Objective-C type

I ended up simply passing an NSString via the annotation.url, and converting that string to an NSURL in the method I was using above. 我最终只是通过注解.url传递了一个NSString,然后按照上面使用的方法将该字符串转换为NSURL。

Oh well. 那好吧。

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

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