0
votes

Context: I have two functions inside my controller that both present a UIImagePickerController with delegate=self

I should do different actions with the image received based on which method spawned de picker

In android I can set a requestCode that behaves like a unique request identifier so when the result comes in delegate function (in this case func imagePickerController) i can differentiate it and i know what to do with it

I don't seem to find anything to differentiate inside delegate function "imagePickerController" so I know which picker caused to method to be called

1

1 Answers

1
votes

You can simply add a variable in your self.

var currentPickerId : Int?

Then when you set the delegate:

picker.delegate = self
currentPickerId = 1

And in your delegate method:

switch currentPickerId {
    case 1: // Do whatever you want
    case 2: // And so on
    default: break
}

// And don't forget to reinit the id, you never know... ;p
currentPickerId = nil