Skip to content

Instantly share code, notes, and snippets.

View licvido's full-sized avatar

Filip Mikovcak licvido

View GitHub Profile
section {
padding-top: 60px;
}
.subnav {
margin-bottom: 60px;
width: 100%;
height: 36px;
background-color: #eeeeee; /* Old browsers */
background-repeat: repeat-x; /* Repeat the gradient */
@licvido
licvido / App.swift
Created July 5, 2014 10:55
SWIFT: Save and load local data
let prefs = NSUserDefaults.standardUserDefaults()
prefs.setObject("Hello World", forKey: "greeting")
let greeting = prefs.stringForKey("greeting")
@licvido
licvido / App.swift
Last active December 31, 2019 00:37
SWIFT: Get application version and build
let version : AnyObject! = NSBundle.mainBundle().objectForInfoDictionaryKey("CFBundleShortVersionString")
let build : AnyObject! = NSBundle.mainBundle().objectForInfoDictionaryKey("CFBundleVersion")
println("Version: \(version)")
println("Build: \(build)")
@licvido
licvido / App.swift
Last active March 12, 2016 21:50
SWIFT: Show modal view controller
let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let loginVC: LoginViewController = storyboard.instantiateViewControllerWithIdentifier("webvc") as LoginViewController
self.presentModalViewController(loginVC, animated:true)
@licvido
licvido / App.swift
Created July 20, 2014 15:49
SWIFT: Shared instance
var APISharedInstance: API? = nil
class API
{
init()
{
APISharedInstance = self
}
@licvido
licvido / App.swift
Created August 30, 2014 16:08
SWIFT: Singleton design pattern
class MyClass
{
class var sharedInstance: MyClass {
struct Static {
static let instance: MyClass = MyClass()
}
return Static.instance
}
}
@licvido
licvido / app.swift
Created February 3, 2015 19:07
SWIFT: Get image from URL
let url = NSURL(string: "http://example.com/images/me.jpg")
let data = NSData(contentsOfURL: url!)
let image = UIImage(data: data!)
@licvido
licvido / app.swift
Created February 3, 2015 19:08
SWIFT: Dispatch async
dispatch_async(dispatch_get_main_queue(),{
// ...
});
@licvido
licvido / NSURLConnection.swift
Created February 3, 2015 19:11
SWIFT: HTTP request
let url = NSURL(string: "http://www.example.com")
let request = NSURLRequest(URL: url!)
NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue()) {(response, data, error) in
// ...
}
@licvido
licvido / app.swift
Created February 3, 2015 23:18
SWIFT: Fade when changing UIImageView's image
let toImage = UIImage(named:"image.png")
UIView.transitionWithView(self.imageView,
duration:5,
options: .TransitionCrossDissolve,
animations: { self.imageView.image = toImage },
completion: nil)