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
// Passing a closure with a reference to `self` which is ultimately stored as | |
// an instance property. Strong reference = retain cycle. | |
collectionView?.addInfiniteScrollWithHandler { collectionView in | |
self.update(false) | |
} | |
// Fixed: Make sure `self` that is being passed is explicitly marked as `weak` | |
// to force a weak reference. | |
collectionView?.addInfiniteScrollWithHandler { [weak self] collectionView in | |
self?.update(false) |
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 Thing { | |
// retain cycle | |
lazy var wifi: Wifi = { | |
return Wifi { state in | |
self.onConnectionHandler(state: state) | |
} | |
}() | |
// no retain cycle |
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
ROOT=$SRCROOT/SellerReports/SupportingFiles | |
cp $ROOT/Configuration.$CONFIGURATION.plist $ROOT/Configuration.plist; |
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
func showWebpage(URL: NSURL) { | |
let vc = SFSafariViewController(URL: URL) | |
let navController = UINavigationController(rootViewController: vc) | |
navController.navigationBarHidden = true | |
RootViewController.sharedInstance.presentViewController(navController, animated: true, completion: nil) | |
} |
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
struct User {} | |
enum ResultType<T> {} | |
enum Auth { | |
case email(email: String, password: String) | |
case facebook | |
func login(completion: ResultType<User> -> Void) { | |
switch self { | |
case .email(let email, let password): |
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
//: Playground - noun: a place where people can play | |
import UIKit | |
typealias JSON = [String: AnyObject] | |
protocol Authable { | |
static func login(params: JSON?, completion: (ResultType<User>) -> Void) | |
static func logout() | |
} |
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
# https://github.com/Quick/Quick/blob/master/Documentation/en-us/InstallingQuick.md#carthage | |
github "Quick/Quick" ~> 0.9.2 | |
github "Quick/Nimble" ~> 4.1.0 | |
# https://github.com/Quick/Quick/blob/master/Documentation/en-us/InstallingQuick.md#carthage | |
github "Alamofire/Alamofire" ~> 3.4 | |
# http://snapkit.io/docs/#carthage | |
github "SnapKit/SnapKit" >= 0.15.0 |
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 script = document.createElement("script"); | |
script.src = "http://code.jquery.com/jquery-latest.min.js"; | |
document.getElementsByTagName("head")[0].appendChild(script); |
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
function shirtIt(name) { | |
var xhr = new XMLHttpRequest(); | |
xhr.onload = function (e) { | |
if (xhr.readyState === 4) { | |
if (xhr.status === 200) { | |
alert(JSON.parse(xhr.responseText)); | |
} | |
} | |
}; |
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
function gifAllTheThings(images) { | |
var div = document.getElementById('my-div'); | |
var index = 0; | |
var duration = 400; // duration of each image. 400 is arbitrary. change as you please | |
setInterval(function() { | |
var image = images[index % arr.length]; | |
div.style.backgroundImage = 'url(' + image + ')'; | |
index++; | |
}, duration); | |
} |