1

I try to convert this ios/objective-c function under delphi Rio 10.3.3

func authorizationController(authorization: ASAuthorization) {
    if let appleIDCredential = authorization.credential as? ASAuthorizationAppleIDCredential { 

    } else if let passwordCredential = authorization.credential as? ASPasswordCredential {

    }
}

I set authorization.credential to be a pointer. Now my problem how with this pointer can I check the IS ASAuthorizationAppleIDCredential before to cast like for example :

if authorization.credential IS ASAuthorizationAppleIDCredential then 
  TASAuthorizationAppleIDCredential.wrap(authorization.credential);
2
  • 1
    Already asked (by you) and answered (by me) here: stackoverflow.com/a/59122544/3164070 Commented Apr 20, 2020 at 23:53
  • @DaveNottage I become old :( :( :( thanks ! Commented Apr 21, 2020 at 7:06

1 Answer 1

1

You would use the isKindOfClass: selector that is in NSobject. In your case

if([authorization.credential isKindOfClass:[AsAuthorizationAppleIDCredential class]])
{ // is that class }

https://developer.apple.com/documentation/objectivec/1418956-nsobject/1418511-iskindofclass?language=objc

EDIT: If you want to only perform one selector on the object you could also check if it performs that selector with respondsToSelector: https://developer.apple.com/documentation/objectivec/1418956-nsobject/1418583-respondstoselector?language=objc

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.