Skip to content

Commit 1d05ccb

Browse files
committed
Inject configuration at init
1 parent 319b33d commit 1d05ccb

2 files changed

Lines changed: 6 additions & 13 deletions

File tree

Demo/ImagePickerDemo/ImagePickerDemo/ViewController.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ class ViewController: UIViewController, ImagePickerDelegate {
4242
config.recordLocation = false
4343
config.allowVideoSelection = true
4444

45-
let imagePicker = ImagePickerController()
46-
imagePicker.configuration = config
45+
let imagePicker = ImagePickerController(configuration: config)
4746
imagePicker.delegate = self
4847

4948
present(imagePicker, animated: true, completion: nil)

Source/ImagePickerController.swift

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Photos
1111

1212
open class ImagePickerController: UIViewController {
1313

14-
open var configuration = Configuration()
14+
let configuration: Configuration
1515

1616
struct GestureConstants {
1717
static let maximumHeight: CGFloat = 200
@@ -91,19 +91,13 @@ open class ImagePickerController: UIViewController {
9191

9292
// MARK: - Initialization
9393

94-
public init(configuration: Configuration? = nil) {
95-
if let configuration = configuration {
96-
self.configuration = configuration
97-
}
94+
public required init(configuration: Configuration = Configuration()) {
95+
self.configuration = configuration
9896
super.init(nibName: nil, bundle: nil)
9997
}
10098

101-
public override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
102-
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
103-
}
104-
105-
required public init?(coder aDecoder: NSCoder) {
106-
super.init(coder: aDecoder)
99+
public required init?(coder aDecoder: NSCoder) {
100+
fatalError()
107101
}
108102

109103
// MARK: - View lifecycle

0 commit comments

Comments
 (0)