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 prefs = NSUserDefaults.standardUserDefaults() | |
prefs.setObject("Hello World", forKey: "greeting") | |
let greeting = prefs.stringForKey("greeting") |
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 version : AnyObject! = NSBundle.mainBundle().objectForInfoDictionaryKey("CFBundleShortVersionString") | |
let build : AnyObject! = NSBundle.mainBundle().objectForInfoDictionaryKey("CFBundleVersion") | |
println("Version: \(version)") | |
println("Build: \(build)") |
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 storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil) | |
let loginVC: LoginViewController = storyboard.instantiateViewControllerWithIdentifier("webvc") as LoginViewController | |
self.presentModalViewController(loginVC, animated:true) |
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
var APISharedInstance: API? = nil | |
class API | |
{ | |
init() | |
{ | |
APISharedInstance = self | |
} | |
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
class MyClass | |
{ | |
class var sharedInstance: MyClass { | |
struct Static { | |
static let instance: MyClass = MyClass() | |
} | |
return Static.instance | |
} | |
} |
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 url = NSURL(string: "http://example.com/images/me.jpg") | |
let data = NSData(contentsOfURL: url!) | |
let image = UIImage(data: data!) |
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
dispatch_async(dispatch_get_main_queue(),{ | |
// ... | |
}); |
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 url = NSURL(string: "http://www.example.com") | |
let request = NSURLRequest(URL: url!) | |
NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue()) {(response, data, error) in | |
// ... | |
} |
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 toImage = UIImage(named:"image.png") | |
UIView.transitionWithView(self.imageView, | |
duration:5, | |
options: .TransitionCrossDissolve, | |
animations: { self.imageView.image = toImage }, | |
completion: nil) |
OlderNewer