-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJxFetchResultViewController.m
More file actions
92 lines (65 loc) · 2.5 KB
/
JxFetchResultViewController.m
File metadata and controls
92 lines (65 loc) · 2.5 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//
// JxFetchResultViewController.m
//
// Created by Jeanette Müller on 16.08.13.
//
#import "JxFetchResultViewController.h"
//#import "Logging.h"
@interface JxFetchResultViewController ()
@end
@implementation JxFetchResultViewController
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
LLog();
if (self.isMovingToParentViewController == NO){
//back buton pressed
}else{
//erster aufruf
}
}
- (void)dealloc{
self.managedObjectContext = nil;
}
#pragma mark - Fetched results controller
- (BOOL)refetchData{
LLog();
NSError *error;
@try {
if ([self.fetchedResultsController performFetch:&error]) {
return YES;
}else{
NSLog(@"Error %@: %@", error, error.description);
}
//NSLog(@"fetchedObjects %@", self.fetchedResultsController.fetchedObjects);
}
@catch (NSException *exception) {
NSLog(@"Exception %@: %@", exception.name, exception.reason);
}
return NO;
}
- (NSFetchedResultsController *)fetchedResultsController{
if (_fetchedResultsController != nil) {
return _fetchedResultsController;
}
//DLog(@"self.entityName: %@", self.entityName);
NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:self.entityName];
fetchRequest.resultType = NSManagedObjectResultType;
if (self.predicate != nil) {
[fetchRequest setPredicate:self.predicate];
}
if (self.sortDescriptors != nil) {
fetchRequest.sortDescriptors = self.sortDescriptors;
}
fetchRequest.returnsObjectsAsFaults = NO;
[fetchRequest setFetchLimit:[self.fetchLimit intValue]];
[fetchRequest setFetchBatchSize:10];
NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest
managedObjectContext:self.managedObjectContext
sectionNameKeyPath:self.sectionKeyPath
cacheName:nil];
aFetchedResultsController.delegate = self;
self.fetchedResultsController = aFetchedResultsController;
NSLog(@"return _fetchedResultsController");
return _fetchedResultsController;
}
@end