-
Notifications
You must be signed in to change notification settings - Fork 1
/
CoreData+Convenience.h
48 lines (30 loc) · 2.14 KB
/
CoreData+Convenience.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//
// CoreData+Convenience.h
// Trend
//
// Created by Alexander Ivanov on 03.09.17.
// Copyright © 2017 Pine 9. All rights reserved.
//
#import <CoreData/CoreData.h>
#import "NSObject+Convenience.h"
@interface NSPersistentContainer (Convenience)
- (void)loadPersistentStores:(void (^)(NSPersistentStoreDescription *description))block;
+ (void)loadPersistentContainerWithName:(NSString *)name completionHandler:(void (^)(NSPersistentContainer *container))block;
@end
@interface NSManagedObject (Convenience)
+ (instancetype)insertInContext:(NSManagedObjectContext *)context;
+ (NSArray *)executeFetchRequestInContext:(NSManagedObjectContext *)context predicate:(NSPredicate *)predicate sortDescriptors:(NSArray<NSSortDescriptor *> *)sortDescriptors fetchLimit:(NSUInteger)fetchLimit;
+ (NSArray *)executeFetchRequestInContext:(NSManagedObjectContext *)context predicate:(NSPredicate *)predicate sortDescriptors:(NSArray<NSSortDescriptor *> *)sortDescriptors;
+ (NSArray *)executeFetchRequestInContext:(NSManagedObjectContext *)context predicate:(NSPredicate *)predicate;
+ (NSArray *)executeFetchRequestInContext:(NSManagedObjectContext *)context predicateWithFormat:(NSString *)format, ... NS_FORMAT_FUNCTION(2, 3);
+ (instancetype)executeFetchRequestInContext:(NSManagedObjectContext *)context firstObject:(NSString *)attributeName;
+ (instancetype)executeFetchRequestInContext:(NSManagedObjectContext *)context lastObject:(NSString *)attributeName;
+ (NSUInteger)countForFetchRequestInContext:(NSManagedObjectContext *)context predicate:(NSPredicate *)predicate;
+ (NSUInteger)countForFetchRequestInContext:(NSManagedObjectContext *)context predicateWithFormat:(NSString *)format, ... NS_FORMAT_FUNCTION(2, 3);
@end
@interface NSManagedObjectContext (Convenience)
- (BOOL)save;
- (__kindof NSManagedObject *)insertObjectForName:(NSString *)entityName;
- (NSArray *)executeFetchRequestWithEntityName:(NSString *)entityName predicate:(NSPredicate *)predicate sortDescriptors:(NSArray<NSSortDescriptor *> *)sortDescriptors fetchLimit:(NSUInteger)fetchLimit;
- (NSUInteger)countForFetchRequestWithEntityName:(NSString *)entityName predicate:(NSPredicate *)predicate;
@end