Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- Xcode Organizer
- WWDC 2021
- AVFoundation
- AppleEvent
- MDM
- App Clip
- actor
- DooC
- User Enrollment
- Hand Pose Detect
- detent
- Xcode Cloud
- ProRAW
- METAL
- Mac
- SF Symbols
- Hand Action Detect
- profile
- async
- SWiFT
- DriverKit
- AR Quick Look
- Object Capture
- SF Symbols 3.0
- NSUserActivity
- concurrency
- CoreML
- Physical Audio
- Reality Composer
- swiftUI
Archives
- Today
- Total
nyancoder
Actor-isolated instance method '' can only be referenced on 'self' 본문
Short answer
Actor-isolated instance method '' can only be referenced on 'self'
nyancoder 2021. 7. 1. 23:47문제 상황
Swift의 Actor에서 다른 Actor의 함수를 접근할 때 발생하는 오류 중 하나로 아래와 같이 발생한다.
해결 방안
해당 함수를 async로 선언하면 발생하지 않는다.
actor TestActor {
func foo(testActor: TestActor) async {
await testActor.bar()
}
func bar() {
}
}
또는 아래와 같이 async 블럭으로 감싸도 된다.
actor TestActor {
func foo(testActor: TestActor) {
async {
await testActor.bar()
}
}
func bar() {
}
}
연관 자료: WWDC 2021 - Protect mutable state with Swift actors
WWDC 2021 - Protect mutable state with Swift actors
원본 영상: https://developer.apple.com/videos/play/wwdc2021/10133/ 이 장에서는 Swift에서 새로 지원되는 Actor의 필요성과 활용에 대해서 알아봅니다. 기존 방식의 문제점 둘 이상의 스레드에서 동일 데이터..
nyancoder.tistory.com
Comments