开发者

Can't instantiate NSURL with file path

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜