Skip to content

Instantly share code, notes, and snippets.

@gitbricho
gitbricho / Comment.swift
Last active January 11, 2016 04:07
IOSSample101
import UIKit
class Comment {
// MARK: プロパティ
var id: Int
var text: String
// MARK: イニシャライザ
init(id:Int, text:String) {
self.id = id
@gitbricho
gitbricho / MovieRepo.swift
Last active January 11, 2016 04:03
IOSSample
import UIKit
class MovieRepo {
// MARK: プロパティ
var movies = [MovieT]()
// MARK: イニシャライザ
init() {
let photo1 = UIImage(named: "movie01")!
@gitbricho
gitbricho / ATS1_info.plist
Last active January 11, 2016 04:21
IOSSample101
...
<plist version="1.0">
<dict>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
...
</dict>
@gitbricho
gitbricho / AppTests.swift
Last active May 2, 2016 07:27
IOSSample101
import XCTest
@testable import App
class AppTests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
@gitbricho
gitbricho / class01_01.swift
Last active June 18, 2016 06:36
swift:class
//: Playground - noun: a place where people can play
import UIKit
//## クラスとストラクチャ #####
//## 定義
struct S住所 {
// MARK:プロパティ
var 郵便番号 = ""
var 都道府県 = ""
var 市区町村 = ""
@gitbricho
gitbricho / collection01_01.swift
Last active June 17, 2016 09:09
swift:collection
import UIKit
//## 配列の定義
//# 空の配列の作成
var v整数配列 = [Int]() //[]
print("v整数配列の要素数:\(v整数配列.count)")
//結果:v整数配列の要素数:0\n
//# 配列に値を追加
v整数配列.append(5) //[5]
@gitbricho
gitbricho / closure01_01.swift
Last active August 19, 2016 09:51
swift:closure
import UIKit
//## シンタックス: {(引数リスト) -> (戻り値) in 文}
//# 変数にクロージャを代入
//例1 {() -> () }
var v引数無し戻り値無し: ()->() = {
print("引数無し戻り値無しのクロージャ")
}
v引数無し戻り値無し() //"引数無し戻り値無しのクロージャ"
@gitbricho
gitbricho / flow01_01.swift
Last active March 27, 2016 05:14
swift:flow
//: Playground - noun: a place where people can play
import UIKit
//## for-in
for i in 1...3 {
//3回繰り返し
}
// 配列の要素の数だけ繰り返して合計を求める
var v合計 = 0
@gitbricho
gitbricho / func01_01.swift
Last active June 17, 2016 12:48
swift:func
import Foundation
//## シンタックス: (パラメータリスト) -> (戻り値)
//## 定義と呼び出し
// 1. (String) -> (String)
func f挨拶(名前: String) -> String {
let l挨拶 = 名前 + "さん、今日は"
return l挨拶
}
// 呼び出し
@gitbricho
gitbricho / file01_01.swift
Last active May 7, 2016 10:44
swift 2.1 ファイル
import UIKit
//## iOS:ファイルシステム #####
//標準ディレクトリ ( Documents/, Library/, tmp/ ... )
//## OS X:ファイルシステム #####
//ローカルドメイン ( Applications/Utilities, Developer/, Library/ )
//ユーザードメイン ( Users/user1, ... )
//ファイルまたはディレクトリのパス