开发者

Can't instantiate NSURL with file path

开发者 https://www.devze.com 2023-04-12 01:23 出处:网络
When creating an NSURL with [NSURL fileURLWithPath:[@\"~/Movies\" stringByExpandingTildeInPa开发者_StackOverflow中文版th]], I get following error in the console:

When creating an NSURL with [NSURL fileURLWithPath:[@"~/Movies" stringByExpandingTildeInPa开发者_StackOverflow中文版th]], I get following error in the console:

-[NSURL initWithScheme:host:path:]: path file:/localhost/Users/michael is not absolute.

It worked while compiling in Debug mode, this problem occured only after switching to Release.

EDIT: Just to clarify, I get the error message at run time when the NSURL object is initialized, not while building.


I think your code needs to look like:

NSURL *url = [NSURL fileURLWithPath:[@"~/Movies" stringByExpandingTildeInPath]];

Looks to me like you are missing the @"" that needs to surround '~/Movies'.


works fine here ...

 NSURL *url = [NSURL fileURLWithPath:[@"~/Movies" stringByExpandingTildeInPath]];
 NSLog(@"url: %@", url);

BUT is your app sandboxed in release mode? That could explain this

0

精彩评论

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

关注公众号