0

When I just going through with a library, there is an Internal property in a Singelton class. like this :-

class CameraHandler: NSObject, UIImagePickerControllerDelegate {

      static let shared = CameraHandler()

     //MARK: Internal Properties
     var imagePickedBlock: ((UIImage) -> Void)?   ///// What kind of property is THIS ???

     func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
       if let image = info[UIImagePickerControllerOriginalImage] as? UIImage {
           self.imagePickedBlock?(image)
       } else{
           print("Something went wrong")
       }
     }

 }

As you can see above imagePickedBlock variable changes when user selects an image. And also below function will fire. So my question is what type of Property is this? Thanks

CameraHandler.shared.imagePickedBlock = { (image) in
     /* get your image here */
     print("Got image!!!!")
}
Arasuvel
  • 2,971
  • 1
  • 25
  • 40
Mudith Chathuranga Silva
  • 7,253
  • 2
  • 50
  • 58

0 Answers0