PKul
PKul

Reputation: 1711

How to Save/Load Image/Videos from Camera Roll

In Obj-C:

picker.sourceType = UIImagePickerControllerSourceTypeCamera;

How would I do the same in Swift?

Upvotes: 1

Views: 849

Answers (1)

Tom Erik Støwer
Tom Erik Støwer

Reputation: 1409

Enums work differently in Swift compared to Objective-C. The type is UIImagePickerControllerSourceType, but the values are accessed with dot notation:

picker.sourceType = UIImagePickerControllerSourceType.Camera

Since the attribute you are setting is already known to be of type UIImagePickerControllerSourceType, you can skip that part and just write:

picker.sourceType = .Camera

Upvotes: 2

Related Questions