开发者

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.

webViewController.webViewURL = annotation.url;

Basically, I have an NSURL stored in annotation.url, and am trying to send this NSURL to webViewController.webViewURL.

When I try running this code, I get "EXC_BAD_ACCESS" in the console. 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...

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


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.

Oh well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜