Hi, I have a whole bunch of .mp3 files that I want to use with NSFileManager and store in a folder with documents. Is there a way to upload .mp3 files on the Internet and then save it in a folder with documents? This is what I use for the local file.
let filemanager = NSFileManager.defaultManager() let documentsPath : AnyObject = NSSearchPathForDirectoriesInDomains(.DocumentDirectory,.UserDomainMask,true)[0] let destinationPath:NSString = documentsPath.stringByAppendingString("/Attention.mp3") if (!filemanager.fileExistsAtPath(destinationPath)) { var theError: NSError? let fileForCopy = NSBundle.mainBundle().pathForResource("Attention",ofType:"mp3") filemanager.copyItemAtPath(fileForCopy!,toPath:destinationPath, error: &theError) if (theError == nil) { println("The music files has been saved.") } else { println("Error") } } else { println("The files already exist") }
user1457381
source share