This file contains 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
/* | |
{ | |
"name": "Archie", | |
"email": "[email protected]", | |
"status: "Active", | |
"updated_time": "2017-09-20T00:00:00Z" | |
} | |
*/ | |
enum UserStatus: String, Codable { |
This file contains 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
/* | |
{ | |
"status": true, | |
"user": { | |
"ID": "1234567890", | |
"name": "Archie", | |
"email": "[email protected]" | |
} | |
*/ |
This file contains 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
/* Create a Foundation object from JSON data. Set the NSJSONReadingAllowFragments option if the parser should allow top-level objects that are not an NSArray or NSDictionary. Setting the NSJSONReadingMutableContainers option will make the parser generate mutable NSArrays and NSDictionaries. Setting the NSJSONReadingMutableLeaves option will make the parser generate mutable NSString objects. If an error occurs during the parse, then the error parameter will be set and the result will be nil. | |
The data must be in one of the 5 supported encodings listed in the JSON specification: UTF-8, UTF-16LE, UTF-16BE, UTF-32LE, UTF-32BE. The data may or may not have a BOM. The most efficient encoding to use for parsing is UTF-8, so if you have a choice in encoding the data passed to this method, use UTF-8. | |
*/ | |
open class func jsonObject(with data: Data, options opt: JSONSerialization.ReadingOptions = []) throws -> Any |
This file contains 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
override var preferredStatusBarStyle: UIStatusBarStyle { | |
return .lightContent | |
} |
This file contains 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
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
return viewModels[indexPath.row].cell(tableView, indexPath: indexPath) | |
} |
This file contains 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
protocol UITableViewCellRepresentable { | |
associatedtype CellType: UITableViewCell | |
func cell(_ tableView: UITableView, indexPath: IndexPath) -> Self.CellType | |
} |
This file contains 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
struct User { | |
var id: String | |
var name: String | |
var age: Int | |
} | |
struct UserViewModel { | |
var title: String | |
var content: String | |
init(user: User) { |
This file contains 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
class ViewController: UIViewController { | |
@IBOutlet private weak var nameTextField: UITextField! { | |
didSet { | |
nameTextField.placeholder = "給值" | |
} | |
} | |
@IBOutlet private weak var passwordTextField: UITextField! { | |
didSet { | |
passwordTextField.placeholder = "給值" | |
} |
This file contains 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
class ViewController: UIViewController { | |
@IBOutlet private weak var nameTextField: UITextField! | |
@IBOutlet private weak var passwordTextField: UITextField! | |
@IBOutlet private weak var addressTextField: UITextField! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
setUpView() | |
} | |
This file contains 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
{ | |
"name": "Archie", | |
"address": { | |
"zipCode": "12345" | |
} | |
} |