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
//: Playground - noun: a place where people can play | |
import UIKit | |
/* | |
ネスト関数でクロージャーを作る。 | |
*/ | |
func outer() -> () ->Void{ | |
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
//: Playground - noun: a place where people can play | |
import UIKit | |
/* | |
参照カウンタの仕組み | |
インスタンスが生成されると1になる。 | |
参照が増えるごとに+1。参照減ると-1。 | |
参照が0になるとインスタンスが破棄される。 | |
*/ |
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
//: Playground - noun: a place where people can play | |
import UIKit | |
var strs : String? = "SOMESTRING" | |
print(strs!.lowercaseString) | |
var a: Int? | |
//var b: Optional<Int> // Int? と同じ意味 |
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
//: Playground - noun: a place where people can play | |
import UIKit | |
enum DeviceType { | |
case PC | |
case SmartPhone | |
case Tablet | |
} |
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
//: Playground - noun: a place where people can play | |
import UIKit | |
/* | |
関数の定義 | |
*/ | |
//引数をとらない関数 | |
func someFunc(){ | |
print("引数も戻り値もない関数") |
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
//: Playground - noun: a place where people can play | |
import UIKit | |
/* | |
プロトコル:実装を伴わない宣言の集合。インターフェース。クラス、構造体、列挙型を定義するとき、プロトコルを指定して、そのプロトコルが宣言しているメソッドなどを宣言。継承できない構造体でも、プロトコルに定義されているインターフェースの実装が保証される。 | |
「用語」 | |
プロトコルを採用する->プロトコルを使ってクラス、構造体、列挙型を定義する |
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
enum Gender { | |
case Male, Female | |
} | |
enum TimeSaleResult { | |
case Normal, Morning, Evening | |
} | |
func TimeSale(hour:Int) -> TimeSaleResult { | |
switch hour { |
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
//: Playground - noun: a place where people can play | |
import UIKit | |
//not good code | |
var photos: [UIImage] = { | |
var images = [UIImage]() | |
for index in 1...8 { | |
let photoName = "nature" + String(index) + ".jpg" |
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
@IBOutlet weak var imageView: UIImageView! { | |
didSet { | |
imageView.image = UIImage.init(named: "photo1")?.withRenderingMode(.alwaysTemplate) | |
imageView.tintColor = UIColor.white | |
} | |
} |
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
rm -rf ~/Library/Caches/CocoaPods | |
rm -rf Pods | |
rm -rf ~/Library/Developer/Xcode/DerivedData | |
pod install | |
OlderNewer