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
| for i in stride(from: 0, to: 100, by: 25){ | |
| // 0, 25, 50, 75 | |
| println(i) | |
| } | |
| for i in stride(from: 0, through: 100, by: 25){ | |
| // 0, 25, 50, 75, 100 | |
| println(i) |
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
| Travis CI メモ | |
| オープンソース向けのCIツール | |
| githubからソースをpull、スクリプトを動作させ、結果を通知する。 | |
| Xcodeのプロジェクトがビルドできる。(OS XのVMが走っている?未確認) | |
| Publicリポジトリであれば無料。 | |
| https://travis-ci.org | |
| Privateリポジトリを扱う場合は、有料のプラン契約が必要。 | |
| 月額129USD(13000JPY程度) |
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 | |
| var str = "Hello, playground" | |
| // Swiftの配列からNSDataへ変換 | |
| var rawArray:[UInt8] = [0x01, 0x02, 0x03]; | |
| let data = NSData(bytes: &rawArray, length: rawArray.count) | |
| print(data) | |
| // バイト列からNSDataに変換 |
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 ViewController: UIViewController { | |
| @IBOutlet weak var display: UILabel? | |
| @IBAction func add(sender: UIButton) { | |
| count++ | |
| } | |
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 | |
| import XCTest | |
| class AsyncTests: XCTestCase { | |
| override func setUp() { | |
| super.setUp() | |
| // Put setup code here. This method is called before the invocation of each test method in the class. | |
| } | |
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
| /usr/bin/plutil -convert xml1 -o - ~/Library/Safari/Bookmarks.plist | grep -E -o '<string>http[s]{0,1}://.*</string>' | grep -v icloud | sed -E 's/<\/{0,1}string>//g' |
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 | |
| import CoreBluetooth | |
| class ViewController: UIViewController, CBCentralManagerDelegate, CBPeripheralDelegate { | |
| let centralManager:CBCentralManager! | |
| var connectingPeripheral:CBPeripheral! | |
| 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
| - (void) peripheral:(CBPeripheral *)aPeripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error | |
| { | |
| // 長さチェック、エラーチェックなどは省略している | |
| NSData *data = characteristic.value; | |
| uint8_t value[2] = {0x00, 0x00}; | |
| [data getBytes:value length:2]; | |
| } |
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
| extension CBCentralManagerState:Printable{ | |
| public var description: String { get { | |
| switch self { | |
| case .Unknown: | |
| return "Unknown" | |
| case .Resetting: | |
| return "Resetting" | |
| case .Unsupported: |
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
| var hello:String? = "Hello" | |
| var goodbye:String? = "Goodbye" | |
| // Swift 1.2 | |
| if let a = hello, b = goodbye { | |
| println(a + " ," + b) | |
| } | |
| // Swift 1.1 | |
| if let a = hello { |