Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jrasmusson committed Jul 15, 2022
1 parent a7da5a9 commit 1a1a172
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ A starter kit for those interested in iOS programming
* [Arrays](https://github.com/jrasmusson/ios-starter-kit/blob/master/basics/Array/README.md)
* [Dictionary Grouping](basics/DictionaryGrouping/README.md)
* [Async](basics/Async/README.md)
* [Actor](basics/Actor/README.md)
* [Enums](https://github.com/jrasmusson/ios-starter-kit/blob/master/basics/Enums/README.md)
* [Computed Properties](https://github.com/jrasmusson/ios-starter-kit/blob/master/swift/Computed-Properties.md)
* [DateFormatter](swift/DateFormatter.md)
Expand Down
28 changes: 28 additions & 0 deletions basics/Actor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Actor

`Actors` serialize access to mutable state.

```swift
actor Counter {
var value = 0

func increment() -> Int [
value = value + 1
return value
}
}

let counter = Counter()
Task.detached {
print(counter.increment()) // 2
}

Task.detached {
print(counter.increment()) // 1
}
```


### Links that help

- [WWDC 2022 Protect mutable state with Swift Actors](https://developer.apple.com/videos/play/wwdc2021/10133)

0 comments on commit 1a1a172

Please sign in to comment.