workaround #100 (NSFetchRequest.affectedStores ARC bug)

This commit is contained in:
John Rommel Estropia
2016-09-27 02:39:28 +09:00
parent f18d62f643
commit 4d2ebe4ea8
6 changed files with 29 additions and 54 deletions

View File

@@ -570,4 +570,13 @@ CORESTORE_EXTERN
CSWhere *_Nonnull CSWherePredicate(NSPredicate *_Nonnull predicate) CORESTORE_RETURNS_RETAINED;
#pragma mark CoreStoreFetchRequest
// Bugfix for NSFetchRequest messing up memory management for `affectedStores`
// http://stackoverflow.com/questions/14396375/nsfetchedresultscontroller-crashes-in-ios-6-if-affectedstores-is-specified
NS_SWIFT_NAME(CoreStoreFetchRequest)
@interface _CSFetchRequest: NSFetchRequest
@end
#endif /* CoreStoreBridge_h */

View File

@@ -218,3 +218,21 @@ CSWhere *_Nonnull CSWherePredicate(NSPredicate *_Nonnull predicate) CORESTORE_RE
return [[CSWhere alloc] initWithPredicate:predicate];
}
#pragma mark CoreStoreFetchRequest
@interface _CSFetchRequest ()
@end
@implementation _CSFetchRequest
- (NSArray<NSPersistentStore *> *)affectedStores {
// Bugfix for NSFetchRequest messing up memory management for `affectedStores`
// http://stackoverflow.com/questions/14396375/nsfetchedresultscontroller-crashes-in-ios-6-if-affectedstores-is-specified
CFBridgingRetain([super affectedStores]);
return [super affectedStores];
}
@end