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 1898078
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:43:22+00:00 2026-05-17T06:43:22+00:00

In my iPhone app I’m loading images using this line of code: UIImage *image

  • 0

In my iPhone app I’m loading images using this line of code:

UIImage *image = [UIImage imageWithData: [NSData dataWithContentsOfURL:url]];

How can I check if I have image loaded? I mean sometimes it doesn’t give any error, but I have blank white space instead of image. I want to check if it was completely loaded and if not, try to do it again.

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-05-17T06:43:23+00:00Added an answer on May 17, 2026 at 6:43 am

    First of all, be aware that dataWithContentsOfURL: is a blocking API and, if used on the main thread, will cause your app to hang until it completes. If you’re using this code on a slow connection such as 3G or EDGE, your app will appear to be unresponsive until the image loads – you don’t want that.

    You should instead consider one of the following options:

    • Using NSURLConnection and it’s delegate methods to download the image data, create an image object and update your UI when it’s finished
    • Use blocks to wrap up your call to dataWithContentsOfURL: and dispatch it on an asynchronous queue
    • Perform this work on a separate thread (not recommended as the previous two options give you the same effect with less code).

    All that is for another question though. As for your actual question you can check whether the returned data object is valid. The docs state that this method returns nil if the data object could not be created.

    If you want to know the reason why it failed, you should use dataWithContentsOfURL:options:error: and pass an error pointer which you can check when it fails.

    However, as I said, if you use the NSURLConnection method you will be able to check its failure reason by implementing the connection:didFailWithError: delegate method.

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

Sidebar

Related Questions

In iPhone App how to store UIImage converted into NSData to sqlite table in
My iPhone app started logging this error: lo->hi recycling invariant violated! followed by: Program
My iPhone app formats an NSDecimalNumber as a currency using setCurrencyCode, however another screen
My iPhone app has a built in RSS reader. There are images and I'd
developing iphone app, I have used a UIImageview and i have set an image
my iphone app is using soap web-services. I want to know how it would
The iPhone app I am working on captures images in series within certain user-defined
In iphone app i am using alertview to check the if textbox values is
Our iPhone app code currently uses NSURLConnection sendSynchronousRequest and that works fine except we
My iPhone App has custom buttons that display png-images. I like to replace the

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.