Getting Image from Web and Displaying it problem
Getting Image from Web and Displaying it problem
- Subject: Getting Image from Web and Displaying it problem
- From: John Tsombakos <email@hidden>
- Date: Fri, 24 Jan 2003 00:22:45 -0500
I have a small app that is just supposed to download an image from the
web and display it in an ImageView. I have an image view in a window,
with a button and everything is wired up correctly. (Which is an
accomplishment in itself, as I'm on the newbie side of Cocoa). The
method the button calls when it's clicked is:
- (IBAction)getImage:(id)sender
{
NSString* string = @"
http://www.rccl.com/rc/image/vywebcam.jpg";
if (string) {
NSURL* url = [NSURL URLWithString:string];
if (url) {
NSData *imageData = [url resourceDataUsingCache:NO];
if (imageData) {
NSImage* image = [[NSImage alloc]
initWith
Data:imageData]; //****
if (image) {
[voyagerImage setImage:image];
} else {
NSLog(@"couldn't init image from imageData
%@\nLoaded from %@\nReferenced by %@\nwith url %@", imageData, url,
string);
}
} else {
NSLog(@"can't init imageData from url %@\n with string
%@", url, string);
}
} else {
NSLog(@"can't init url from string %@", url);
}
} else {
NSLog(@"couldn't get a string from sender %@", sender);
}
}
Now, it sometimes works, but at the line marked with **** it will
generate a message in the debug pane or put the line in the console:
"Application transferred too few scanlines".
I have no idea why! Is this the best way to do this?
Thanks!
jt
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.