NSURL *url = [NSURL URLWithString:@"http://locationofurlonlocalhost.mp4"];
...
NSMutableURLRequest *req;
req = [NSMutableURLRequest requestWithURL:url // <-- CRASH IS HERE!! thx to a breakpoint stepthrough
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:30.0];
a log of url will result in:
Printing description of url:
<NSURLRequest http://locationofurlonlocalhost.mp4>
the crash will log
-[NSURLRequest absoluteURL]: unrecognized selector sent to instance 0x88003e0
The URL looks just fine so I’m not sure what’s going on. Could this happen because the url is unreachable the simulator? I can connect to the url on the sim’s safari as well as my desktop safari. What should I do?
** EDIT **
it’s been determined that the url object is being released too early. In the ... the url is passed to a different selector and then the rest of the code takes place there. How can I force retain the url? I have already tried:
__strong NSURL *url = [[NSURL alloc] initWithString:@"http://locationofurlonlocalhost.mp4"];
This most definitely looks like your url has been released somehow. If you print the description of the
urlvariable and wind up with anNSURLRequest, then you’re looking at freed up memory.Try using alloc / initWithString: as a troubleshooting step.