How to use the Key Value Observer in Swift?

For my purpose, I set up AVFoundation to take photos, and I want to make sure the exposure and white balance (Exposure Adjustment, WhiteBalance Adjustment) are complete before they save the images. Otherwise, it becomes dark for the first photo.

How do I set up a key value observer to run code after values ​​change? And how / where is the best place to launch it?

+3


source to share


1 answer


After you get the image, do var

with didSet

and this var will save the image ex

var image : UIImage{//or what type your image is,Maby NSData,but I'm not sure
didSet{
   // adjustingExposure and adjustingWhiteBalance
 }

      



and then save EX:

func grabImage(){//is an example IDK your code,I say that this func captured the imagedate
image = imageThatYouTook
//then save the image data from the image var
}

      

+3


source







All Articles