Victor Choi

  • Home
  • Business
    • Internet
    • Market
    • Stock
  • Parent Category
    • Child Category 1
      • Sub Child Category 1
      • Sub Child Category 2
      • Sub Child Category 3
    • Child Category 2
    • Child Category 3
    • Child Category 4
  • Featured
  • Health
    • Childcare
    • Doctors
  • Home
  • Business
    • Internet
    • Market
    • Stock
  • Downloads
    • Dvd
    • Games
    • Software
      • Office
  • Parent Category
    • Child Category 1
      • Sub Child Category 1
      • Sub Child Category 2
      • Sub Child Category 3
    • Child Category 2
    • Child Category 3
    • Child Category 4
  • Featured
  • Health
    • Childcare
    • Doctors
  • Uncategorized

8/15/2016

Why did I get the result nil through dataTaskWithURL ?

 3:54 PM     dataTaskWithURL, iOS Networking, NSURLSession     No comments   

If you use dataTaskWithURL , your intention might be getting a data from server and display the data to your UI. But, sometimes it makes a problem that the resulted data is nil.

To solve this issue, first of all you must recognize that dataTaskWithURL runs asynchronously. Conversely UI stuffs runs on the main thread on iOS. So the time that you get a data from the server might not be synced with the time you display the data to your UI. So in this case you might see a strange nil value on it.

You can simply think that I can run it sychronously. But, it would cause a bad user experience. So here is a solution which is creating another completionHandler to run it asynchronously. And then if you want to update your UI , remember that the task should be taken on main queue.

  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Email ThisBlogThis!Share to XShare to Facebook
Newer Post Older Post Home

0 개의 λŒ“κΈ€:

Post a Comment

Search This Blog

Popular Posts

  • How to put a padding into a UITextField ?
  • Time machine gives error "can't connect to a current time machine backup disk"
  • Keynote Tutorial Text Outline - Make your animation meaningful
  • Keynote Tutorial , Sound is a design,too
  • Keynote Tutorial How to improve your bullets

Blog Archive

  • ►  2020 (2)
    • ►  January (2)
  • ►  2019 (21)
    • ►  December (2)
    • ►  November (6)
    • ►  October (5)
    • ►  September (2)
    • ►  August (3)
    • ►  July (2)
    • ►  June (1)
  • ►  2017 (11)
    • ►  December (2)
    • ►  November (2)
    • ►  July (2)
    • ►  May (1)
    • ►  April (1)
    • ►  March (3)
  • ▼  2016 (48)
    • ►  December (3)
    • ►  November (2)
    • ►  September (1)
    • ▼  August (10)
      • Simple Migration Options for CoreData PersistentSt...
      • New Fitbit Flex 2 , Fitbit Charge 2 and Apple Wat...
      • How can I use San Francisco mono font in Xcode7 ?
      • Why did I get the result nil through dataTaskWithU...
      • How can I change the modal transition of a present...
      • How to point your Godaddy domain to a2Hosting
      • The relationship between AnchorPoint and Position ...
      • How can I start UIBezierPath animation from the to...
      • How to securely use xmlrpc
      • My experience on Upthere
    • ►  July (5)
    • ►  June (7)
    • ►  May (2)
    • ►  April (18)
Powered by Blogger.

Navigation Menu

  • Home
  • About
  • Documentation
  • Contact

Contact Us

Name

Email *

Message *

Copyright © Victor Choi | Powered by Blogger
Design by Hardeep Asrani | Blogger Theme by NewBloggerThemes.com | Distributed By Gooyaabi Templates