Challenge: Create Async GooglyEyes | raywenderlich.com


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/9461083-ios-concurrency-with-gcd-and-operations/lessons/8

Hi Audrey
I am wondering if creating a strong ref to weak self in closure capture list is necessary? is it only to get rid of question marks when using weak self within the closure?
Many Thanks:)

hi Ahmad! it’s to make sure self still exists, in case the user has moved away from this view controller.

Swift 5.3 removes the need to use self. in some closures.

1 Like

Many thanks Audrey :slightly_smiling_face:

Hi Audrey

Thank you for the tutorial. I have a question here.
Is it required to call self.fadeInNewImage(overlayImage) in DispatchQueue.main since in the asyncGooglyEyes() we are calling the completion handler on the main queue itself.

Thanks

hi Shruti! you’re right, the Main Thread Checker doesn’t complain when I comment out DispatchQueue.main in the completion handler.

Thank you Audrey for the prompt reply and clarification. Enjoying the tutorial!

1 Like

An observation that may help other who might encounter the same: the face features CIDetector is not working for me on a iPhone Simulator on an M1 Mac mini.

It does work on an Intel Mac (2015 MBP) and on actual iOS devices.

  • iOS Device running iOS 14.4: WORKS
  • Xcode 12.4 / iOS 14.4 Sim / Intel Mac (macOS 11.2.1): WORKS
  • Xcode 12.4 / iOS 14.4 Sim / M1 Mac mini (macOS 11.2.1): DOES NOT WORK
2 Likes

thanks David! I noticed this when I replied to Shruti from my M1, and discussed it with Caroline Begbie (Metal book author). We worked out the same conclusions, but then I forgot to post. Thanks so much for your post!

1 Like

Hi Audrey,

Not sure why when calling asyncGooglyEyes, inside the block you dispatch fadeInNewImage on main thread. Isn’t the block already on main thread?

hi Lucian, you’re right, but only because the default value of completionQueue is the main queue. I guess it’s just safer to maintain the habit of dispatching to main.