Skip to content

Instantly share code, notes, and snippets.

@soffes
Created June 11, 2014 21:02
Show Gist options
  • Save soffes/dd532d6f82050c46cb9d to your computer and use it in GitHub Desktop.
Save soffes/dd532d6f82050c46cb9d to your computer and use it in GitHub Desktop.
class APIClient {
}
var sharedAPIClient: APIClient = {
return APIClient()
}()
extension APIClient {
class func sharedClient() -> APIClient {
return sharedAPIClient
}
}
@subdigital
Copy link

What's the benefit of wrapping line 4 in a closure and then invoking it? Isn't this just running the code and initializing APIClient immediately?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment