• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Issue with the downloading url
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Issue with the downloading url


  • Subject: Re: Issue with the downloading url
  • From: Jean-Daniel Dupas <email@hidden>
  • Date: Fri, 7 Nov 2008 15:41:46 +0100


Check the server response.

NSError *error;
NSHTTPURLResponse *response = nil;
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL
URLWithString:@"http://yp.shoutcast.com/sbin/tunein-station.pls? id=9907"]];
NSData *data = [NSURLConnection sendSynchronousRequest:request
returningResponse:&response error:&error];
if (!data) [NSApp presentError:error];


NSLog(@"Response status: %ld, %@", (long)[response statusCode],
[NSHTTPURLResponse localizedStringForStatusCode:[response statusCode]]);




Le 7 nov. 08 à 15:30, Arnab Ganguly a écrit :

[data writeToFile:@"/tmp/station.pls" atomically:YES]; ->Works perfectly
when I download a html file for example I change the code to [data
writeToFile:@"/tmp/station.html" atomically:YES]


Issue I get is

NSError *error; NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL
URLWithString:@"http://yp.shoutcast.com/sbin/tunein-station.pls?id=9907 "]];
NSData *data = [NSURLConnection sendSynchronousRequest:request
returningResponse:nil error:&error];
if (!data) [NSApp presentError:error];


the download happens perfectly when the URLWithString is an html file but if
it is a pls file like the example given above fails.No download happens at
all.
Thanks
Arnab


On Fri, Nov 7, 2008 at 7:51 PM, Simon Wigzell <email@hidden> wrote:

Probably won't help you, but you should never assume that you know what
file path separators are used by the system like you do here:


[data writeToFile:@"/tmp/station.pls" atomically:YES];

This is wrong; "/" is not necessarily the separator in the file path. The
fact that you see a path listed like this in the terminal is just a
presentation thing; in certain really old Carbon apps you would see ":" used
as the delimiter on the same file system (try using ":" in a file name form
the Finder and you'll notice this is not possible). And if I remember
correctly, HFS+ uses ":" as the separator but translates this to "/" for
users higher up... See NSPathUtilities.h for the correct way of handling
file paths.


Simon Wigzell


On 7 Nov 2008, at 13:56, Arnab Ganguly wrote:

Hi Al,
Thanks for all help but unfortunately the problem still persists.With the
below code the data is not null but when I write to a file I don't get
anything.
I have used the following for writing [data writeToFile:@
"/tmp/station.pls"
atomically:YES]; but the file size remains zero.
Also I tried printing [NSApp presentError:error]; even when the data is
not
null and I get "-[NSAlert alertWithError:] called with nil NSError. A
generic error message will be displayed, but the user deserves better.".
Is it something silly I am doing?
Thanks in advance


NSError *error;  NSURLRequest *request = [NSURLRequest
requestWithURL:[NSURL
URLWithString:@"http://yp.shoutcast.com/sbin/tunein-station.pls?id=9907
"]];
NSData *data = [NSURLConnection sendSynchronousRequest:request
returningResponse:nil error:&error];
if (!data) [NSApp presentError:error];


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Issue with the downloading url (From: "Arnab Ganguly" <email@hidden>)
 >Re: Issue with the downloading url (From: Jean-Daniel Dupas <email@hidden>)
 >Re: Issue with the downloading url (From: "Arnab Ganguly" <email@hidden>)
 >Re: Issue with the downloading url (From: Jean-Daniel Dupas <email@hidden>)
 >Re: Issue with the downloading url (From: "Arnab Ganguly" <email@hidden>)
 >Re: Issue with the downloading url (From: "Arnab Ganguly" <email@hidden>)

  • Prev by Date: Open/Show window from external NIB
  • Next by Date: Cocoa Application to front End for MySQL Database
  • Previous by thread: Re: Issue with the downloading url
  • Next by thread: Re: Issue with the downloading url
  • Index(es):
    • Date
    • Thread