Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

erritikamathur

macrumors newbie
Original poster
Sep 23, 2009
8
0
i m trying to download mp3 file from server but i m not getting any data

i m getting error as
Error {
NSLocalizedDescription = "bad URL";
NSUnderlyingError = Error Domain=kCFErrorDomainCFNetwork Code=-1000 UserInfo=0x1183ac0 "bad URL";
}
here is my code----
Code:
sender=@"http://sound13.mp3pk.com/indian/7days/7days01(www.songs.pk).mp3";
NSMutableURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:sender]
                                              cachePolicy:NSURLRequestUseProtocolCachePolicy
                                          timeoutInterval:60.0];
     // create the connection with the request
    // and start loading the data
	NSURLResponse *res=NULL;
	NSError *error=NULL;
	NSData *data=[NSURLConnection sendSynchronousRequest:theRequest returningResponse:&res error:&error];
	NSLog(@"download data---%@",[res URL]);

i need to store the data received from server.i cn't figure where i m missing&if i provided any path with .wma file or anything else it gets downloaded
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
You cannot use quite a few characters in a URL. See here.

You need to encode your URL. There is an obvious method of NSString. I'll leave it to you to open the documentation and find it.
 

erritikamathur

macrumors newbie
Original poster
Sep 23, 2009
8
0
I m aware that we can't use few characters in URL,so i m sending encoded URlL only by converting string url into URL by method [NSURL URLWithString:sender]

then also i m not able to download mp3 file.
if in case i send path for any other type of file i can easily download it my same method.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.