Having set up a Twitter sharing function in an iOS app, I have a question. Here is the code, it is based on what I have found, browsing the net:
func shareImageOnTwitter() {
if SLComposeViewController.isAvailableForServiceType(SLServiceTypeTwitter){
let twit = SLComposeViewController(forServiceType: SLServiceTypeTwitter)
// Do all the necessary local cooking for whatever we want to share ………….
} else {
// In which case are we suppose to be here ?????
var alert = UIAlertController(title: "Accounts", message: "Please login to a Twitter account to share.", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
}
}
Let me say that it is basically working. But the question is when do we reach the second branch of the if
.
That is where my comment (// In which case are we suppose to be here ?????) is.
I have made a few experiments to prevent Twitter from working, I then get other messages, but never the ones in the code above. So when is exactly this code supposed to execute? In which exact conditions?