I need require开发者_运维知识库ment for downloads songs and save them in iPhone memory using iphoneSDK, How can I implement to download the song and save to iPhone memory programmatically?
Quick one-liner:
NSData * theMusic = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://www.domain.com/Music.mp3"]];
EDIT
In addition how to save the NSData object to the local storage.
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
NSString *documentsDirectory = [paths objectAtIndex:0]; 
if ([theMusic writeToFile:[documentsDirectory stringByAppendingPathComponent:@"theMusic.mp3"] atomically:YES]) {
    // Success !
} else {
    // Error !  
}
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论