Nsbundle.Mainbundle().Urlforresource("Bach1", Withextension: "Jpg") Returning Null

NSBundle.mainBundle().URLForResource(bach1, withExtension: jpg) returning null

Your problem is that NSBundle.mainBundle().URLForResource("bach1", withExtension: "jpg") returns an optional NSURL. You need to use if let to unwrap it and extract your file path from the returned url as follow:

if let resourceUrl = NSBundle.mainBundle().URLForResource("bach1", withExtension: "jpg") {
if NSFileManager.defaultManager().fileExistsAtPath(resourceUrl.path!) {
print("file found")
}
}

Fatal Error with NSURL ofType MP4

Make sure the file it is in the proper format. Use your finder to get info of your file and check if the More Info: Codecs: it is showing H.264, AAC.



Related Topics



Leave a reply



Submit