NSString *path = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"mp4"];
NSLog(@"Path: %@", path);
NSURL *url = [NSURL URLWithString:path];
NSLog(@"URL: %@", url);
NSData *data = [NSData dataWithContentsOfURL:url];
NSLog(@"Data exists? %@", data ? @"yes" : @"no");
test.mp4是我的包,但是這始終是輸出數據總是空...不知道爲什麼
2013-03-13 11:50:29.444 videoAppPrototype[28625:907] Path: /var/mobile/Applications/D66DD820-4DE1-4E45-9495-9BACF130E368/videoAppPrototype.app/test.mp4
2013-03-13 11:50:29.446 videoAppPrototype[28625:907] URL: /var/mobile/Applications/D66DD820-4DE1-4E45-9495-9BACF130E368/videoAppPrototype.app/test.mp4
2013-03-13 11:50:29.448 videoAppPrototype[28625:907] Data exists? no
我不知道爲什麼,但數據永遠不會存在。
,你一定'存在於應用程序捆綁test.mp4'? – trojanfoe 2013-03-13 15:55:07
可能重複的[URLWithString返回nil的資源路徑-iphone](http://stackoverflow.com/questions/2112927/urlwithstring-returns-nil-for-resource-path-iphone) – trojanfoe 2013-03-13 16:08:44