Last active
January 11, 2016 04:07
-
-
Save gitbricho/e416f1268f7eb118cee0 to your computer and use it in GitHub Desktop.
IOSSample101
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 Comment { | |
// MARK: プロパティ | |
var id: Int | |
var text: String | |
// MARK: イニシャライザ | |
init(id:Int, text:String) { | |
self.id = id | |
self.text = text | |
} | |
} |
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 MovieT { | |
// MARK: プロパティ | |
var name:String | |
var photo:UIImage? | |
var rating: Int | |
// MARK: イニシャライザ | |
init?(name:String, photo:UIImage?, rating: Int) { | |
// プロパティの初期化 | |
self.name = name | |
self.photo = photo | |
self.rating = rating | |
// name が空または rating が負の場合は初期化失敗 | |
if name.isEmpty || rating < 0 { | |
return nil | |
} | |
} | |
} |
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 Product { | |
// MARK: プロパティ | |
var id: Int | |
var name: String | |
var price: Int | |
var inStock: String | |
var comments: [Comment] | |
// MARK: イニシャライザ | |
init(id:Int, name:String, price:Int, inStock: String, comments: [Comment]) { | |
self.id = id | |
self.name = name | |
self.price = price | |
self.inStock = inStock | |
self.comments = comments | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment