I w开发者_高级运维ant to send an mp3 file from music library from my iphone over wifi. So I need a way to get NSData of mp3 file. Is it possible? How can i access it?
NSString *msg = [[NSBundle mainBundle] pathForResource:@"Rab" ofType:@"mp3"];
NSData* data =[[NSData alloc]init];
data = [NSData dataWithContentsOfFile:msg];
use
[NSData dataWithContentsOfFile:filePath]
Since iOS 4, you can use AVFoundation and MPMediaPickerController to export songs from the library. It's not simple, but it's doable. See http://www.subfurther.com/blog/2010/07/.
The current API does not allow you to access the user's media library in this way.
You may want to try using method:
(id)dataWithContentsOfURL:(NSURL *)aURL
精彩评论