Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9191965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:48:51+00:00 2026-06-17T20:48:51+00:00

I have problems to obtain image from url on iPad 3 4G test device.

  • 0

I have problems to obtain image from url on iPad 3 4G test device.
Code works with ipad 1 & 2 and also with iphone 3gs and iphone 4.
But seems that image is nil when requested from server.

I don’t experience the issue, but clients report problems…

I belive that problem is in the following code

Code:

NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.image.com/img_download/499441.jpg"]];
UIImage *thumbnail = [UIImage imageWithData:data];

Url in this code is not real but it is correct for clarification.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T20:48:52+00:00Added an answer on June 17, 2026 at 8:48 pm

    A couple of thoughts:

    1. I’d suggest using dataWithContentsOfURL:options:error: instead of just dataWithContentsOfURL and reporting the error code is. Or use NSURLConnection or other framework (e.g. AFNetworking?) that might provide greater diagnostic information. But I suspect that dataWithContentsOfURL:options:error: can provide the necessary error information.

    2. Can you place this in context? For example, is this something that your app is doing asynchronously (e.g. thumbnails for a tableview)? If so, are you using NSOperationQueue with a reasonably small maxConcurrentOperationCount rather than a global dispatch queue, to make sure you don’t exceed the number of permissible concurrent connections?

      For example, if you’re updating your tableview like so:

      dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0), ^{
          NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"image.com/img_download/499441.jpg"]];
          UIImage *thumbnail = [UIImage imageWithData:data];
      
          // presumably you're updating your UI like so
          dispatch_async(dispatch_get_main_queue(), ^{
              // update UI
          });
      });
      

      you should do the following. First, define a class property:

      @property (nonatomic, strong) NSOperationQueue *queue;
      

      Second, you should initialize this in viewDidLoad, specifying how many concurrent operations are acceptable:

      self.queue = [[NSOperationQueue alloc] init];
      self.queue.maxConcurrentOperationCount = 4;
      

      And finally, replace dispatch_async with:

      [self.queue addOperationWithBlock:^{
          NSError *error = nil;
          NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"image.com/img_download/499441.jpg"]
                                               options:0
                                                 error:&error];
      
          if (error)
          {
              // log or display what the error is
          }
          else
          {
              UIImage *thumbnail = [UIImage imageWithData:data];
      
              if (thumbnail)
              {
                  // update UI in the main queue
      
                  [[NSOperationQueue mainQueue] addOperationWithBlock:^{
      
                      // make sure the cell is still visible
      
                      UITableViewCell *updateCell = [tableView cellForRowAtIndexPath:indexPath];
      
                      // if so, update the image
      
                      if (updateCell)
                      {
                          updateCell.imageView.image = thumbnail;
                      }
                  }];
              }
          }
      }];
      

      Note, you may also want to do caching to eliminate reloading images that you’ve already downloaded. See https://stackoverflow.com/a/14444605/1271826 for an example. You could also cache images to Documents folder if you want to cache images across sessions (though some care must be done to determine changes in images).

    To my second point, sometimes connection problems are not caused by the particular line that fails, but is a symptom of a broader problem, and as such, we need a little more info about how you’re using the code in your question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have problems to obtain good thumb from some images, when the original images
I have problems to get rspec running properly to test validates_inclusion_of my migration looks
I am having problems trying to obtain a dataUrl for an image taken with
I have this code $arr['... key'] = 'value'; this works and not return error,
i have problems with a really basic thing. setting properties after instantiation a UIViewController-
I have problems with creating a simple Group-Box-Control via CreateWindowEx. The font-size/-style of its
I have problems with CSS. The table is creating white border and I do
I have problems dealing with ProGuard and Android. I searched on the web for
I have problems trying to load png file into my application. It seems to
I have problems binding both a telerik RadGrid and a plain vanilla ASP.NET GridView

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.