Post

Replies

Boosts

Views

Activity

Comment on NSFetchedResultsController use-after-free issues in iOS 16.1
The solution to 1. is to avoid returning section names in an order that does not match the sort descriptor's ordering. The docs explicitly state that you must do this, though the resulting memory corruption seems like a bug. I'm not certain of a general solution to 2., but you might try adding an additional copy call to the strings returned from sectionNameKeyPath, or converting the implementation to Swift. Both of these seemed to work in the sample project I submitted to Apple.
Nov ’22
Comment on NSFetchedResultsController use-after-free issues in iOS 16.1
@cliffr one of the crashing instances we observed appeared to be due to the use of uppercaseStringWithLocale when returning the section header. The workarounds we found were to either rewrite that code in Swift or to copy the uppercased string before returning it. Assuming that you're using ARC, copying will also autorelease, which appears to be sufficient to make the strings live through whatever internal loop in CoreData that isn't explicitly retaining them long enough.
Mar ’23