ARTICLE AD BOX
I increased the target version, and xcode started giving me an error
Expression is 'async' but is not marked with 'await'" on each usage of NSManagedObjectContext.perform().
let context: NSManagedObjectContext = ... context.perform{...}It thinks I use newer method
NSManagedObjectContext.perform<T>(schedule::() throws -> T) async rethrows -> T,
but I don't.
How to make xcode to compile with old perform(() -> Void)?
Adding explicit closure header
let context: NSManagedObjectContext = ... context.perform{() -> Void in ...}is not helpful.
5,8847 gold badges60 silver badges104 bronze badges
Your call must have been in an async context. Apparently in an async context, Swift prioritises resolving to async methods.
You can have it resolve to the non-async method by introducing a synchronous context. For example, you can write a local function like this
func someAsyncFunction() async { func helper() { someContext.perform { ... } } helper() }More generally, you can write
func run<R>(block: () -> R) -> R { block() } ... func someAsyncFunction() async { run { someContext.perform { ... } } }294k23 gold badges262 silver badges442 bronze badges
Explore related questions
See similar questions with these tags.
