This file contains hidden or 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 a = 1 | |
0 ..< 10 ~= a // true |
This file contains hidden or 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 UIKit | |
protocol TestModelDelegate { | |
func display(something: NSObject) | |
} | |
class TestModel: NSObject { | |
var displayedString: String | |
var delegate: TestModelDelegate? |
This file contains hidden or 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 hexString = "FF" | |
var hex:UInt32 = 0x0 | |
let scanner:NSScanner = NSScanner(string: hexString) | |
scanner.scanHexInt(&hex) | |
print(hex) //255 |
This file contains hidden or 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 array = [Int](0 ..< 10000) | |
let number = array[1000] // number = 1000 |
This file contains hidden or 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 Foundation | |
let candidates = ["ガルパン", "は", "いい", "ぞ"] | |
var createdPhrase = [String](count: candidates.count, repeatedValue: "") | |
for i in 0 ..< Int.max { | |
if createdPhrase != candidates { | |
let randomNumber = Int(arc4random_uniform(UInt32(candidates.count))) | |
let nextWord = candidates[randomNumber] | |
print(nextWord) |
This file contains hidden or 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 Person { | |
var car: Car? | |
func goForADrive() { | |
self.car?.drive() | |
} | |
func buyGasoline() { |
This file contains hidden or 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
//普通に distanceTo を使うからこの方法やめる | |
//extension Range where Element: IntegerType { | |
extension Range { | |
//普通に distanceTo を使うからこの方法やめる | |
//var distance: Element { | |
// return self.endIndex - self.startIndex | |
//} | |
var distance: Element.Distance { |
This file contains hidden or 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
% swift iLoveYou.swift 春彦母 | |
私は春彦母のことが好きです |
This file contains hidden or 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 UIKit | |
class ChildViewController: UIViewController { | |
init() { | |
super.init(nibName: nil, bundle: nil) | |
print("Child controller inited") | |
} | |
required init?(coder aDecoder: NSCoder) { |
This file contains hidden or 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 Foundation | |
struct GCD { | |
enum Thread { | |
case Main | |
case Static(queue: dispatch_queue_t) | |
case Dynamic(name: String, attribute: QueueAttribute) |