Created
May 27, 2025 17:06
-
-
Save pookjw/bbd0d8feff83f28297874e1de2fdedc1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import CoreData | |
extension NSManagedObjectContext { | |
@available(macOS, deprecated: 12, renamed: "performAndWait(_:)") | |
@available(iOS, deprecated: 15.0, renamed: "performAndWait(_:)") | |
func old_performAndWait<T>(_ block: () throws -> T) rethrows -> T { | |
try withoutActuallyEscaping(block) { _block in | |
var result: Result<T, Error>? | |
performAndWait { | |
do { | |
result = try .success(_block()) | |
} catch { | |
result = .failure(error) | |
} | |
} | |
return try result.unsafelyUnwrapped.get() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment