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
Swift - How to Set Cookie in Nsmutableurlrequest
Using Guard with a Non-Optional Value Assignment
Can't Pass Date to Nspredicate(Format: ...) Without "As Cvararg"
Swift Error: Missing Argument Label 'Name:' in Call
Calculate Area of Mkpolygon in an Mkmapview
Not Condition in 'If Case' Statement
Early Return from a Void-Func in Swift
Resize a Sklabelnode Font Size to Fit
Use Uipangesturerecognizer to Drag Uiview Inside Limited Area
Does Swift Have an Implicit Object Initializer, Like in C#
Image Upload in Vapor 3 Using Postgresql
Scenekit Shadow on a Transparent Scnfloor()
Nsstatusitem in Nsstatusbar, Action Selector Method Not Responding
Which Swift Character Count Should I Use When Interacting with Nsstring APIs
Binary Operator '===' Cannot Be Applied to Operands of Type 'Any' and 'Uibarbuttonitem!'