【问题标题】:Incompatible Objective-C types - trying to pass NSURL不兼容的 Objective-C 类型 - 试图传递 NSURL
【发布时间】:2011-03-09 07:10:06
【问题描述】:

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

webViewController.webViewURL = annotation.url;

基本上,我在 annotation.url 中存储了一个 NSURL,并试图将此 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

【问题讨论】:

  • 能否也发布一下 webViewURL 属性是如何配置的以及它是如何以及在哪里发布的?

标签: ios memory-management webview nsurl


【解决方案1】:

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

哦,好吧。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多