Here's an example from HockeyApp that generates the following code:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { BITHockeyManager.sharedHockeyManager().configureWithIdentifier(API_KEY) BITHockeyManager.sharedHockeyManager().disableCrashManager = true BITHockeyManager.sharedHockeyManager().startManager() BITHockeyManager.sharedHockeyManager().authenticator.authenticateInstallation() return true } Notice the repetition of BITHockeyManager.sharedHockeyManager() in each call. I'm looking for a syntax that does something like (pseudo code):
with BITHockeyManager.sharedHockeyManager() do { .configureWithIdentifier(API_KEY) .disableCrashManager = true .startManager() .authenticator.authenticateInstallation() } Is there a way to do this in Swift?
Edit: After writing this question I noticed that Alamofire is using "chainable methods" , which actually is originally what I was looking for. This allows a neat syntax, as follows (code from http://nshipster.com/alamofire/):
Alamofire.request(.GET, "http://httpbin.org/get") .response { (request, response, data, error) in println(request) println(response) println(error) } To use the corresponding syntax with HockeyApp would require modifying the BITHockeyManager class.