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

时间:2011-03-09 07:10:06

标签: ios memory-management webview nsurl

我有这行代码,我试图将自定义MKAnnotation上的注释的URL分配给UIWebView控制器。

webViewController.webViewURL = annotation.url;

基本上,我有一个NSURL存储在annotation.url中,我正在尝试将此NSURL发送到webViewController.webViewURL。

当我尝试运行此代码时,我在控制台中获得“EXC_BAD_ACCESS”。运行分配工具(使用NSZombiesEnabled)没有显示任何僵尸......我无法理解为什么会发生这种情况,尤其是因为如果我将线路更改为使用“URLWithString ...”并构建新的NSURL ..

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

......虽然我收到了警告:Incompatible Objective-C types 'struct NSURL *', expected 'struct NSString *' when passing argument 1 of 'URLWithString:' from distinct Objective-C type

,但它没有问题

1 个答案:

答案 0 :(得分:0)

我最后只是通过annotation.url传递一个NSString,并在我上面使用的方法中将该字符串转换为NSURL。

哦,好吧。