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 | 29 | 30 |
Tags
- CoreML
- SF Symbols 3.0
- MDM
- Physical Audio
- App Clip
- Mac
- Xcode Organizer
- DooC
- SWiFT
- Hand Action Detect
- swiftUI
- NSUserActivity
- AppleEvent
- AVFoundation
- METAL
- detent
- ProRAW
- SF Symbols
- DriverKit
- WWDC 2021
- Hand Pose Detect
- Object Capture
- profile
- Xcode Cloud
- Reality Composer
- actor
- concurrency
- async
- User Enrollment
- AR Quick Look
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
Comments