How to check if UIActivityTypeAirDrop exists

I am using UIActivityViewController to show a common leaflet in some iOS apps. iOS 7 introduces a new type of UIActivity : UIActivityTypeAirDrop .

This is declared as an extern line in the UIActivity.h file ... Essentially, I'm trying to exclude the airdrop type from my shared page, which works fine, but this set of codes should be backward compatible with previous versions of iOS.

I know that to test a method that I can use respondsToSelector: but is there any similar method that I can use to check if a string is declared, or do I need to resort to including a version of the system? (Which is never a good way to normal)

+6
source share
1 answer

UIActivityTypeAirDrop is an NSString constant, which will essentially be a pointer, so you can check if this pointer is NULL. If this is not the case, this type of activity exists, and you can exclude it. Otherwise, do nothing.

 if (&UIActivityTypeAirDrop != NULL) { activityViewController.excludedActivityTypes = @[UIActivityTypeAirDrop]; } 
+9
source

Source: https://habr.com/ru/post/954249/


All Articles