Group Group Group Group Group Group Group Group Group

raywenderlich.com Forums

Video Tutorial: iOS App Extensions Part 3: Photo Extensions: Loading Data

Learn how to load adjustment data in a Photo Extension.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/4173-ios-app-extensions/lessons/4
1 Like
  1. The resources came with OS X tags, but apparently, tags only come with color information, not what that color meant to the user who did the tagging. What do Orange and Yellow mean on your end?

  2. The version of canHandleAdjustmentData in the challenge document can’t actually compile anymore, although the version in the project can. Is it actually important to cast adjustmentData.data to an NSData?, or is this enough?

guard let adjustmentData = adjustmentData
where
   adjustmentData.formatIdentifier == "com.razeware.hipsterize"
   && ["1.0", "2.0"].contains(adjustmentData.formatVersion)
else {return false}

return true

Jesse, do you mean the downloaded resources had color tags on the folders. I think I had just used the colors so that I would know which versions to archive into the zip. On my end, I have lots of similar looking folders. That said, orange = orange and red = red. nothing more than that :wink:

  • Tim

Yes, your solution works. You are returning true as long as the guard doesn’t fail.

BTW it does compile for me. Are you using Xcode 7.3?

I’ve never put effort into tagging; do you think it’s a worthwhile endeavor?

The version in ChallengeDetails.pdf doesn’t compile, but the version in ChallengeFinished does. The difference is a cast from adjustmentData.data, which is an NSData, to an NSData?, which can be tested for nil. I don’t have enough experience to know for sure, if, when performing such a cast, the result could actually be nil, if, for example, there had been no actual data, but I’m thinking that it’s actually impossible for the test for adjustmentData.data as NSData? != nil to ever be false, hence me testing the check’s removal in my code above. (I had success doing so.)

I’m thinking that maybe, when the original version of this series was created, PHAdjustmentData.data was optional, and that Apple changed it to not be, since then. If so, I’m hoping it was done for good reason, but as someone new to much of this, it’s confusing!