I am trying to develop an application which downloads online music data (music files) and makes them available when I am offline.
Can anyone he开发者_运维百科lp me? What is the best way to do that?
I like ASIHTTPRequest framework for downloading. You may also use standard NSURLRequest, but as for me it's not as easy-to-use as ASIHTTPRequest.
Update: To save file, you may use Documents directory:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *documentsDirectory = [paths objectAtIndex:0];
To save loaded data into a file, use
- (BOOL)writeToFile:(NSString *)path atomically:(BOOL)flag
To load:
+ (id)dataWithContentsOfFile:(NSString *)path
精彩评论