Files
RestKit/Code/Three20/RKObjectLoaderTTModel.h
Blake Watters f2ceefa012 Merge Request Queue (See issue #75):
* Introduces RKRequestCache for cacheing responses (supports ETag conditional GET, use cache if available, use cache on error, etc.) closes #75
    * Updates to Three20 layer to eliminate need for intermediary TTTableItem classes closes #76
    * Fixes to ensure iOS 3.x compatability:
        * Switched compiler to Clang
        * Updated conditional checks for UIBackgroundTask symbols to ensure runtime safety on iOS 3.x
        * Removed unnecessary linkage against UIKit and CoreFoundation from library targets
    * Fix for issue where RKRequest objects could become stuck in infinite loop within RKRequestQueue loadNextInQueue if you start
      a request and then cancel immediately. On cancel only decrement loadCount if the request has start loading. refs #122
2011-06-11 19:28:44 -04:00

93 lines
2.7 KiB
Objective-C

//
// RKObjectLoaderTTModel.h
// RestKit
//
// Created by Blake Watters on 2/9/10.
// Copyright 2010 Two Toasters. All rights reserved.
//
#import <Three20/Three20.h>
#import "../RestKit.h"
/**
* Generic class for loading a remote model using a RestKit object loader and supplying the model to a
* TTListDataSource subclass
*/
@interface RKObjectLoaderTTModel : TTModel <RKObjectLoaderDelegate> {
NSArray *_objects;
BOOL _isLoaded;
BOOL _isLoading;
BOOL _cacheLoaded;
BOOL _emptyReloadAttempted;
RKObjectLoader* _objectLoader;
NSTimeInterval _refreshRate;
}
/////////////////////////////////////////////////////////////////////////
/// @name Global Configuration
/////////////////////////////////////////////////////////////////////////
/**
* The NSDate representing the first time the app was run. This defaultLoadedTime
* is used in comparison with refreshRate in cases where a resourcePath-specific
* loadedTime has yet to be established for a given resourcePath.
*/
+ (NSDate*)defaultLoadedTime;
/**
* App-level default refreshRate used in determining when to refresh a given model.
* Defaults to NSTimeIntervalSince1970, which essentially means all app models
* will never refresh.
*/
+ (NSTimeInterval)defaultRefreshRate;
/**
* Setter for defaultRefreshRate, which allows one to set an app-wide refreshRate
* for all models, as opposed to having to set the refreshRate on every instantiation
* of RKRequestTTModel.
*/
+ (void)setDefaultRefreshRate:(NSTimeInterval)newDefaultRefreshRate;
/////////////////////////////////////////////////////////////////////////
/// @name Accessing Model Data
/////////////////////////////////////////////////////////////////////////
/**
* Domain objects loaded via this model
*/
@property (nonatomic, readonly) NSArray* objects;
/**
* The object loader responsible for loading the data accessed via this model
*/
@property (nonatomic, readonly) RKObjectLoader* objectLoader;
/**
* The NSDate object representing the last time this model was loaded.
*/
@property (nonatomic, readonly) NSDate* loadedTime;
/**
* The rate at which this model should be refreshed after initial load.
* Defaults to the value returned by + (NSTimeInterval)defaultRefreshRate.
*/
@property (assign) NSTimeInterval refreshRate;
+ (RKObjectLoaderTTModel*)modelWithObjectLoader:(RKObjectLoader*)objectLoader;
- (id)initWithObjectLoader:(RKObjectLoader*)objectLoader;
/**
* Load the model
*/
- (void)load;
//// TODO: Does this work?
//// Loads a new object loader
//- (void)changeModelWithObjectLoader:(RKObjectLoader*)objectLoader;
// [model didChange]
//
//- (void)filterWithPredicate:(NSPredicate*)predicate sortDescriptors:(NSArray*)sortDescriptors;
//- (void)searchWithText:(NSString*)text predicate: sortDescriptors:
@end