Created
February 28, 2016 07:09
-
-
Save shu223/385f0ab0dd811f90bd2a to your computer and use it in GitHub Desktop.
Open one of Twitter apps with username
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let username = organizer.twitter | |
let twitterURLs = [ | |
"twitter://user?screen_name=\(username)", // Twitter | |
"tweetbot://user_profile/\(username)", // TweetBot | |
"echofon://user_timeline?\(username)", // Echofon | |
"twit://user?screen_name=\(username)", // Twittelator Pro | |
"x-seesmic://twitter_profile?twitter_screen_name=\(username)", // Seesmic | |
"x-birdfeed://user?screen_name=\(username)", // Birdfeed | |
"tweetings://user?screen_name=\(username)", // Tweetings | |
"simplytweet://?link=http://twitter.com/\(username)", // SimplyTweet | |
"icebird://user?screen_name=\(username)", // IceBird | |
"fluttr://user/\(username)", // Fluttr | |
] | |
var applicationOpened: Bool = false | |
let application = UIApplication.sharedApplication() | |
for twitterURL in twitterURLs { | |
if let url = NSURL(string: twitterURL) where application.canOpenURL(url) && !applicationOpened { | |
application.openURL(url) | |
applicationOpened = true | |
break | |
} | |
} | |
if !applicationOpened { | |
let webViewController = WebDisplayViewController() | |
webViewController.url = NSURL(string: "http://twitter.com/\(username)")! | |
webViewController.displayTitle = "@\(username)" | |
navigationController?.pushViewController(webViewController, animated: true) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
from https://github.com/NatashaTheRobot/trySwiftApp/blob/master/trySwift/OrganizersTableViewController.swift