Jump to content
Sign in to follow this  
alejandro.sawers

iOS Selectors in Delphi

Recommended Posts

iOS has a convenient way to save images to the user's device without requiring full access to the photo library, and luckily the required call is included in the iOSapi.UIKit unit in Delphi. So just doing something like this:

UIImageWriteToSavedPhotosAlbum(NSObjectToID(Image), nil, nil, nil);	// Image is a TUIImage instance

And the system will take care of asking the corresponding user authorization and saving the image.

 

Now if something goes wrong (from the user denying authorization to some failure on the save process) the app can get error info by filling the 2nd and 3rd parameter when calling the procedure. These parameters are quite special however: a Selector and its Target. According to the documentation I understand that a Selector allows to call an arbitrary procedure of a NSObject regardless of its class.

 

Given a FMX TForm with a procedure CompletionHandler to act as the completion receiver:

- Can a FMX TForm be casted to a NSObject to be used as completonTarget?

- Is the procedure signature CompletionHandler(image: UIImage; error: NSError; contextInfo: Pointer) correct and suitable?

- It's enough something like NSSelectorFromString(NSObjectToID(StrToNSStr('CompletionHandler'))) to make a Selector for a Delphi method name?

- Will be possible to pass a valid Selector on Delphi at all?

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×