Search code examples
phpiphonesql-serverjsontouchjson

Json and images


I've got a db on a server and want to get some data fro my iphone. I use TouchJson and everything works fine but I've got a little problem. I don't know how to download images. When I try to build and run the app the emulator just crashes. Got any ideas what to do?


Solution

  • If your JSON request provides a URL to the image then try:

    NSString *path = @"http://sstatic.net/so/img/logo.png";
    NSURL *url = [NSURL URLWithString:path];
    NSData *data = [NSData dataWithContentsOfURL:url];
    UIImage *image = [UIImage imageWithData:data];