Permalink
Browse files

Added a fetchTotal property to SKFetchRequest, courtesy @cbguder

  • Loading branch information...
1 parent bb0d847 commit f0c92b9909f9fd1ae5162d9f85dc738e246f153d @davedelong committed Aug 7, 2010
Showing with 8 additions and 0 deletions.
  1. +2 −0 Classes/SKFetchRequest.h
  2. +6 −0 Classes/SKFetchRequest.m
View
@@ -34,6 +34,7 @@
NSSortDescriptor * sortDescriptor;
NSUInteger fetchLimit;
NSUInteger fetchOffset;
+ NSNumber * fetchTotal;
NSPredicate * predicate;
NSError * error;
@@ -47,6 +48,7 @@
@property (retain) NSSortDescriptor * sortDescriptor;
@property NSUInteger fetchLimit;
@property NSUInteger fetchOffset;
+@property (readonly) NSNumber * fetchTotal;
@property (retain) NSPredicate * predicate;
@property (readonly, retain) NSError * error;
@property (assign) id<SKFetchRequestDelegate> delegate;
View
@@ -31,6 +31,7 @@ @implementation SKFetchRequest
@synthesize sortDescriptor;
@synthesize fetchLimit;
@synthesize fetchOffset;
+@synthesize fetchTotal;
@synthesize predicate;
@synthesize error;
@synthesize delegate;
@@ -41,6 +42,8 @@ @implementation SKFetchRequest
NSString * SKErrorCodeKey = @"code";
NSString * SKErrorMessageKey = @"message";
+NSString * SKFetchTotalKey = @"total";
+
- (id) initWithSite:(SKSite *)aSite {
if (self = [super initWithSite:aSite]) {
fetchLimit = SKPageSizeLimitMax;
@@ -54,6 +57,7 @@ - (id) init {
}
- (void) dealloc {
+ [fetchTotal release];
[sortDescriptor release];
[predicate release];
[error release];
@@ -179,6 +183,8 @@ - (NSArray *) executeFetchRequest {
return nil;
}
+ fetchTotal = [[responseObjects objectForKey:SKFetchTotalKey] retain];
+
//check for an error in the response
NSDictionary * errorDictionary = [responseObjects objectForKey:SKErrorResponseKey];
if (errorDictionary != nil) {

0 comments on commit f0c92b9

Please sign in to comment.