Post

Replies

Boosts

Views

Activity

Reply to iOS18 Crash FetchedProperty CoreData
The bug is real, even the official Apple's guide Linking Data Between Two Core Data Stores crashes on launch on iOS 18.0. It would help if Apple Engineers could have a look at this solution: How about manually fetching the corresponding records from Core Data? In the Apple's example, instead of extension Book { var feedbackList: [Feedback]? { // The accessor of the feedbackList property. return value(forKey: "feedbackList") as? [Feedback] } } have something like: import CoreData extension Book { var feedbackList: [Feedback]? { // The accessor of the feedbackList property. if #available(iOS 18.1, *) { //iOS 18.1+ usual code (current) return value(forKey: "feedbackList") as? [Feedback] } else if #available(iOS 18, *) { //iOS 18.0-18.1 only code return fetchFeedbackManually() } else { //below iOS 18.0 usual code return value(forKey: "feedbackList") as? [Feedback] } } private func fetchFeedbackManually() -> [Feedback]? { guard let viewContext = self.managedObjectContext, let bookUUID = self.uuid else { return nil } return viewContext.performAndWait { let request: NSFetchRequest<Feedback> = Feedback.fetchRequest() request.predicate = NSPredicate(format: "bookUUID == %@", bookUUID as CVarArg) do { return try viewContext.fetch(request) } catch { return nil } } } } It seems to work, but I can't say what the consequences of such an approach are...
Feb ’25
Reply to What is the current proper way to load an image from local filesystem?
@DTS Engineer is correct. I ended up utilizing the new URL's static variable like URL.applicationSupportDirectory and the new method appending(path:directoryHint:) and the final code is: func findImage(name: String) -> UIImage? { let url = URL.applicationSupportDirectory .appending(path: "MyFolder", directoryHint: .isDirectory) .appending(path: "\(name).png", directoryHint: .notDirectory) return UIImage(contentsOfFile: url.path(percentEncoded: false)) } Writing this as an answer to checkout the final code. Don't know whether there is a better way than UIImage(contentsOfFile:) but it does the job for now ¯\ _ (ツ) _ /¯
Topic: App & System Services SubTopic: General Tags:
Jul ’24