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 inputDictionary = [ | |
"author_name": "Robert Jordan", | |
"book_title": "Knife of Dreams", | |
"series": "The Wheel of Time, Book 11", | |
"publisher": "Tor Fantasy", | |
"published_date": "November 28, 2006" | |
] | |
let sortedKeys = inputDictionary.keys.array.sorted(<) | |
var queryTerms = Array<String>() |
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
//: # Lazy Instantiation | |
//: | |
//: This playground demonstrates situations where lazily instantiating properties is valuable. | |
//: **NOTE:** This is a Swift 2.0 playground and must be opened in Xcode 7. | |
import UIKit | |
import CoreImage | |
//: A helper function to produce a random CGFloat in the range 0..<1 | |
func randomCGFloat() -> CGFloat { |
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 attemptLogin(user: String, password: String) { | |
self.loginRequest = APIClient.sharedClient().createLoginRequest(user:user, password:password) { | |
result in | |
switch result { | |
case .Success(let data): | |
parseLoginData(data) // Compiler error: implicit reference to self | |
case .Failure(let error): | |
errorHandlingMethod(error) // Compiler error: implicit reference to 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 { | |
@IBOutlet weak var outputLabel: UILabel! { | |
didSet { | |
// Ensure that the label wasn't just set to nil. | |
guard let outputLabel = self.outputLabel else { return } | |
// Set the text color based on the user's style choices. | |
outputLabel.textColor = StyleManager.sharedManager().outputLabelColor | |
// Set the label to use fixed-width numbers. |
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 TouchCaptureControl: UIControl { | |
var value: CIVector = CIVector(x: 0.0, y: 0.0) | |
@IBInspectable var horizontalMinimumValue: CGFloat = 0.0 | |
@IBInspectable var horizontalMaximumValue: CGFloat = 1.0 | |
@IBInspectable var verticalMinimumValue: CGFloat = 0.0 | |
@IBInspectable var verticalMaximumValue: CGFloat = 1.0 | |
@IBInspectable var flipHorizontalAxis: Bool = false | |
@IBInspectable var flipVerticalAxis: Bool = 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 SingleWave { | |
float SEGMENTS_PER_CYCLE = 48.0; | |
float wavelength, r, dr; | |
color drawColor; | |
SingleWave(float wavelength, color drawColor) { | |
this.wavelength = wavelength; | |
this.drawColor = drawColor; |
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
static float FOCAL_LENGTH = 200.0; | |
static float ORBIT_RADIUS = 180.0; | |
static int SPARK_COUNT = 200; | |
class Spark { | |
color clr; | |
float orbitRadius; | |
float rx, ry, rz, drx, dry, drz; | |
Spark(color c, float orbitRadius) { | |
this.clr = c; |
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
import Swift | |
/// This method returns half of the input value if the number is even. It returns nil if the number is odd. | |
func evenHalfOrNil(input: Int) -> Int? { | |
if (input % 2 == 0) { | |
return input / 2 | |
} else { | |
return 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
// | |
// ViewController.swift | |
// MetalCoreImage | |
// | |
// Created by Joshua Sullivan on 4/21/16. | |
// Copyright © 2016 The Nerdery. All rights reserved. | |
// | |
import UIKit | |
import MetalKit |
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
//: # Challenge Accepted #49 | |
//: ## WUnderground API Client | |
//: ### Version 2.0 | |
//: | |
//: Implement the networking layer for the Umbrella weather app(iOS or Android), | |
//: using a similar architecture to the one demonstrated in the first episode of Swift Talks. | |
//: | |
//: - note: | |
//: This is my updated solution to the challenge which demonstrates a more powerful and flexible | |
//: approach to customizing the request sent to the API through the use of closures rather than |
OlderNewer