Dispatch Groups

  1. Make a new PROJECT in xcode
  2. Make two methods, one called getNewPhotos(completion: () -> Void) and the other called uploadPhotos(completion: () -> Void)
  3. Both methods should get a random number between 0 and 10, print out the random number, and write NSThread.sleepForTimeInterval(YourRandomTimeHere)
  4. Make both methods completion blocks that complete when they are done
  5. In the viewDidLoad, call both methods and then (once both are done) print "All done!"
  6. Notice that they run one at a time and then finally print All Done!
  7. Try running both methods at the same time by adding dispatch_async to both of the methods (see GCD stretch problem
  8. What issues arise?

Once finished, we'll go over a solution together.