Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting Image from URL/server
    primarykey
    data
    text
    <p>I'm fairly new to iPhone development and trying to fetch 'Images from Server' in my application.</p> <p>I'm using the following method to do this:</p> <pre><code>- (UIImage *)imageFromURLString:(NSString *)urlString { NSURL *url = [NSURL URLWithString:urlString]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url]; [request setHTTPMethod:@"GET"]; NSURLResponse *response = nil; NSError *error = nil; NSData *result = [NSURLConnection sendSynchronousRequest:request returningResponse:&amp;response error:&amp;error]; [request release]; [self handleError:error]; UIImage *resultImage = [UIImage imageWithData:(NSData *)result]; NSLog(@"urlString: %@",urlString); return resultImage; } </code></pre> <p>This function does not return the expected image although I can see in debugger that NSData for the Image object has some value (in bytes)</p> <p>Although, a very similar function for getting text from server works and I get expected values.</p> <pre><code>- (NSString *)jsonFromURLString:(NSString *)urlString { NSURL *url = [NSURL URLWithString:urlString]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url]; [request setHTTPMethod:@"GET"]; NSURLResponse *response = nil; NSError *error = nil; NSData *result = [NSURLConnection sendSynchronousRequest:request returningResponse:&amp;response error:&amp;error]; [request release]; [self handleError:error]; NSString *resultString = [[NSString alloc] initWithData:result encoding:NSUTF8StringEncoding]; return [resultString autorelease]; } </code></pre> <p>This method works fine.</p> <p>Could someone please help me in understanding why I'm not getting the Image from server?</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload