Reputation: 1878
I am using google chart functionality in iPhone app....I want to download image and put it into UIImageView from http://chart.apis.google.com/chart?cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World ... Is there any sample app for doing such functionality?or any other way to display charts in app?
Thanks in advance...
Upvotes: 1
Views: 1090
Reputation: 13364
@iSwap - I know that why your code is not working.
i think you put an url as a string instead of url. as above code ----
imageView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:aURL]];
there is aURL that should be a url not a string, and u wrote it as a string like
imageView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:@"http://chart.apis.google.com/chart?cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World"]];
you have been forget to convert this string into an url.
the right method will be like this-
imageView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://chart.apis.google.com/chart?cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World"]]];
i hope you got it, and one more thing there is no difference between "willcodejavaforfood" and "CodeBrickie" code. just way of writing is little differ.
Upvotes: 0
Reputation: 44093
This would block, use NSURLConnection for non-blocking download
NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://chart.apis.google.com/chart?cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World"]];
UIImage *downloadedImage = [UIImage imageWithData:imageData];
myImageView.image = downloadedImage;
Upvotes: 2
Reputation: 10389
Try imageView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:aURL]]
Upvotes: 0