Ios/swift/構造体
提供: 初心者エンジニアの簡易メモ
構造体サンプル
struct SmartPhone { var os:String var version:Double var width:Int var height:Int } var iPhone6 = SmartPhone(os: "iOS", version: 8.3, width: 375, height: 667) print(iPhone6.width) // 375
参考:http://qiita.com/yuinchirn/items/98b568d595650eca3334
initを使う構造体サンプル
struct SmartPhone_Init { let os:String let version:Double let width:Int let height:Int init(os: String, version: Double, width: Int, height: Int) { self.os = os self.version = version self.width = width self.height = height } } var iPhone6_init= SmartPhone_Init(os: "iOS", version: 8.3, width: 375, height: 667) print(iPhone6_init.width) // 375