|
|
|
|
|
by DrJokepu
3812 days ago
|
|
Cocoa and Cocoa Touch were designed with imperative programming in mind though, so this is what the creators of Swift had to work with. I think the main use case for mutable captured values is mutable self, in particular the following, extremely common pattern: dispatch_async(my_background_queue) {
do_some_io()
let result = do_expensive_computation()
dispatch_async(dispatch_get_main_queue()) {
self.value = result
update_ui()
}
}
|
|