简体   繁体   中英

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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