Upload
jens-ravens
View
174
Download
1
Tags:
Embed Size (px)
Citation preview
TABLE VIEWS▸ Data Source is just a protocol▸ Android: ListAdapter▸ WWDC 2014,
Session 232: Advanced User Interfaces with Collection Views
FASCADES FOR DEPENDENCIESA facade is an object that provides a simplified interface to a larger
body of code, such as a class library
You can use a protocol and class extensions to ensure interface conformance in your objects.
SERVICE class ViewController: UIViewController {
@IBOutlet var tableView: UITableView! let messageService = MessageService.sharedInstance let locationService = LocationService.sharedInstance
}
MUTABILITY class Message: NSObject { var text = "" var recipient: String? }
var messages: [Message]
▸ there might be a message without a recipient ▸ properties might change at any given time
▸ react to notifications and KVO
IMMUTABILITY struct Message { let text: String let recipient: String }
let message = Message(text: "Hello World!", recipient: "Marc")
▸ properties can’t change▸ structs are value types - methods become side effects free!
▸ value types are thread safe by default
HOW TO CHANGE THE UNCHANGEABLE?▸ have a service for model operations
▸ callbacks deliver new object instead of updated one func loadMessages(completion:(([Message]?, NSError?)->())?)
▸ attach new objects to NSNotification payload