Monkaaay macrumors 6502 Original poster Jun 19, 2006 258 0 Richmond, VA Jul 16, 2006 #1 I'm trying to read the contents of a URL and I came across the NSURLRequest and NSURLConnection objects. I have a NSMutableData object filled with the results but I can't find a way to print that data to the screen. Any ideas?
I'm trying to read the contents of a URL and I came across the NSURLRequest and NSURLConnection objects. I have a NSMutableData object filled with the results but I can't find a way to print that data to the screen. Any ideas?
Monkaaay macrumors 6502 Original poster Jun 19, 2006 258 0 Richmond, VA Jul 16, 2006 #2 Well, I found this solution but I wish it were more elegant. Code: unsigned char byteBuffer[[receivedData length]]; [receivedData getBytes:byteBuffer]; NSLog(@"Output: %s", (char *)byteBuffer);
Well, I found this solution but I wish it were more elegant. Code: unsigned char byteBuffer[[receivedData length]]; [receivedData getBytes:byteBuffer]; NSLog(@"Output: %s", (char *)byteBuffer);
HiRez macrumors 603 Jan 6, 2004 6,310 2,751 Western US Jul 16, 2006 #3 How about NSString *s = [[NSString alloc] initWithData:urlData encoding:NSASCIIStringEncoding]; NSLog(@"%@", s); [s release]; Not sure if that's really any better though.
How about NSString *s = [[NSString alloc] initWithData:urlData encoding:NSASCIIStringEncoding]; NSLog(@"%@", s); [s release]; Not sure if that's really any better though.
GeeYouEye macrumors 68000 Dec 9, 2001 1,670 10 State of Denial Jul 17, 2006 #4 HiRez said: How about NSString *s = [[NSString alloc] initWithData:urlData encoding:NSASCIIStringEncoding]; NSLog(@"%@", s); [s release]; Not sure if that's really any better though. Click to expand... Or just use stringWithContentsOfURL:encoding: (I think that's the method...) Also, NSLog(s) would work as well.
HiRez said: How about NSString *s = [[NSString alloc] initWithData:urlData encoding:NSASCIIStringEncoding]; NSLog(@"%@", s); [s release]; Not sure if that's really any better though. Click to expand... Or just use stringWithContentsOfURL:encoding: (I think that's the method...) Also, NSLog(s) would work as well.