Cleaned up broken specs for iOS.

This commit is contained in:
Blake Watters
2011-11-22 16:24:22 -05:00
parent 5b718890ac
commit f5008ff9fe
58 changed files with 2424 additions and 236 deletions

View File

@@ -334,7 +334,20 @@ static NSString* const RKManagedObjectStoreThreadDictionaryEntityCacheKey = @"RK
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
return basePath;
if (basePath) {
// In unit tests the Documents/ path may not exist
if(! [[NSFileManager defaultManager] fileExistsAtPath:basePath]) {
NSError* error = nil;
if(! [[NSFileManager defaultManager] createDirectoryAtPath:basePath withIntermediateDirectories:NO attributes:nil error:&error]) {
NSLog(@"%@", error);
}
}
return basePath;
}
return nil;
#else
@@ -406,7 +419,7 @@ static NSString* const RKManagedObjectStoreThreadDictionaryEntityCacheKey = @"RK
if (nil == [entityCache objectForKey:entityName]) {
NSFetchRequest* fetchRequest = [[[NSFetchRequest alloc] init] autorelease];
[fetchRequest setEntity:entity];
[fetchRequest setReturnsObjectsAsFaults:NO];
[fetchRequest setReturnsObjectsAsFaults:NO];
objects = [NSManagedObject executeFetchRequest:fetchRequest];
RKLogInfo(@"Caching all %d %@ objects to thread local storage", [objects count], entity.name);
NSMutableDictionary* dictionary = [NSMutableDictionary dictionary];

View File

@@ -3,7 +3,7 @@
// RestKit
//
// Created by Blake Watters on 12/1/10.
// Copyright 2010 Two Toasters
// Copyright 2010 RestKit
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -29,12 +29,12 @@
*/
@interface RKRequestQueue : NSObject {
NSString *_name;
NSMutableArray* _requests;
NSObject<RKRequestQueueDelegate>* _delegate;
NSMutableArray *_requests;
NSObject<RKRequestQueueDelegate> *_delegate;
NSUInteger _loadingCount;
NSUInteger _concurrentRequestsLimit;
NSUInteger _requestTimeout;
NSTimer* _queueTimer;
NSTimer *_queueTimer;
BOOL _suspended;
BOOL _showsNetworkActivityIndicatorWhenBusy;
}
@@ -43,7 +43,7 @@
A symbolic name for the queue. Used to return existing queue references
via [RKRequestQueue queueWithName:]
*/
@property (nonatomic, retain, readonly) NSString* name;
@property (nonatomic, retain, readonly) NSString *name;
/**
* The delegate to inform when the request queue state machine changes
@@ -51,7 +51,7 @@
* If the object implements the RKRequestQueueDelegate protocol,
* it will receive request lifecycle event messages.
*/
@property(nonatomic, assign) NSObject<RKRequestQueueDelegate>* delegate;
@property(nonatomic, assign) id<RKRequestQueueDelegate> delegate;
/**
* The number of concurrent requests supported by this queue
@@ -101,7 +101,7 @@
@see [RKClient requestQueue]
*/
+ (RKRequestQueue*)sharedQueue DEPRECATED_ATTRIBUTE;
+ (RKRequestQueue *)sharedQueue DEPRECATED_ATTRIBUTE;
/**
Set the global queue
@@ -110,7 +110,7 @@
@see [RKClient requestQueue]
*/
+ (void)setSharedQueue:(RKRequestQueue*)requestQueue DEPRECATED_ATTRIBUTE;
+ (void)setSharedQueue:(RKRequestQueue *)requestQueue DEPRECATED_ATTRIBUTE;
/**
Returns a new auto-released request queue
@@ -121,34 +121,34 @@
Returns a new retained request queue with the given name. If there is already
an existing queue with the given name, nil will be returned.
*/
+ (id)newRequestQueueWithName:(NSString*)name;
+ (id)newRequestQueueWithName:(NSString *)name;
/**
Returns queue with the specified name. If no queue is found with
the name provided, a new queue will be initialized and returned.
*/
+ (id)requestQueueWithName:(NSString*)name;
+ (id)requestQueueWithName:(NSString *)name;
/**
Returns YES when there is a queue with the given name
*/
+ (BOOL)requestQueueExistsWithName:(NSString*)name;
+ (BOOL)requestQueueExistsWithName:(NSString *)name;
/**
* Add an asynchronous request to the queue and send it as
* as soon as possible
*/
- (void)addRequest:(RKRequest*)request;
- (void)addRequest:(RKRequest *)request;
/**
* Cancel a request that is in progress
*/
- (void)cancelRequest:(RKRequest*)request;
- (void)cancelRequest:(RKRequest *)request;
/**
* Cancel all requests with a given delegate
*/
- (void)cancelRequestsWithDelegate:(NSObject<RKRequestDelegate>*)delegate;
- (void)cancelRequestsWithDelegate:(NSObject<RKRequestDelegate> *)delegate;
/**
* Cancel all active or pending requests.
@@ -163,7 +163,7 @@
/**
* Returns YES if the specified request is in this queue
*/
- (BOOL)containsRequest:(RKRequest*)request;
- (BOOL)containsRequest:(RKRequest *)request;
@end
@@ -171,53 +171,53 @@
* Lifecycle events for RKRequestQueue
*
*/
@protocol RKRequestQueueDelegate
@protocol RKRequestQueueDelegate <NSObject>
@optional
/**
* Sent when the queue has been suspended and request processing has been halted
*/
- (void)requestQueueWasSuspended:(RKRequestQueue*)queue;
- (void)requestQueueWasSuspended:(RKRequestQueue *)queue;
/**
* Sent when the queue has been unsuspended and request processing has resumed
*/
- (void)requestQueueWasUnsuspended:(RKRequestQueue*)queue;
- (void)requestQueueWasUnsuspended:(RKRequestQueue *)queue;
/**
* Sent when the queue transitions from an empty state to processing requests
*/
- (void)requestQueueDidBeginLoading:(RKRequestQueue*)queue;
- (void)requestQueueDidBeginLoading:(RKRequestQueue *)queue;
/**
* Sent when queue transitions from a processing state to an empty start
*/
- (void)requestQueueDidFinishLoading:(RKRequestQueue*)queue;
- (void)requestQueueDidFinishLoading:(RKRequestQueue *)queue;
/**
* Sent before queue sends a request
*/
- (void)requestQueue:(RKRequestQueue*)queue willSendRequest:(RKRequest*)request;
- (void)requestQueue:(RKRequestQueue *)queue willSendRequest:(RKRequest *)request;
/**
* Sent after queue has sent a request
*/
- (void)requestQueue:(RKRequestQueue*)queue didSendRequest:(RKRequest*)request;
- (void)requestQueue:(RKRequestQueue *)queue didSendRequest:(RKRequest *)request;
/**
* Sent when queue received a response for a request
*/
- (void)requestQueue:(RKRequestQueue*)queue didLoadResponse:(RKResponse*)response;
- (void)requestQueue:(RKRequestQueue *)queue didLoadResponse:(RKResponse *)response;
/**
* Sent when queue has canceled a request
*/
- (void)requestQueue:(RKRequestQueue*)queue didCancelRequest:(RKRequest*)request;
- (void)requestQueue:(RKRequestQueue *)queue didCancelRequest:(RKRequest *)request;
/**
* Sent when an attempted request fails
*/
- (void)requestQueue:(RKRequestQueue*)queue didFailRequest:(RKRequest*)request withError:(NSError*)error;
- (void)requestQueue:(RKRequestQueue *)queue didFailRequest:(RKRequest *)request withError:(NSError *)error;
@end
@@ -230,11 +230,11 @@
@interface UIApplication (RKNetworkActivity)
@property (nonatomic, assign, readonly) NSInteger rk_networkActivityCount;
@property (nonatomic, assign, readonly) NSInteger networkActivityCount;
- (void)rk_pushNetworkActivity;
- (void)rk_popNetworkActivity;
- (void)rk_resetNetworkActivity;
- (void)pushNetworkActivity;
- (void)popNetworkActivity;
- (void)resetNetworkActivity;
@end

View File

@@ -195,7 +195,7 @@ static const NSTimeInterval kFlushDelay = 0.3;
#if TARGET_OS_IPHONE
if (self.showsNetworkActivityIndicatorWhenBusy) {
[[UIApplication sharedApplication] rk_pushNetworkActivity];
[[UIApplication sharedApplication] pushNetworkActivity];
}
#endif
} else if (_loadingCount > 0 && count == 0) {
@@ -208,7 +208,7 @@ static const NSTimeInterval kFlushDelay = 0.3;
#if TARGET_OS_IPHONE
if (self.showsNetworkActivityIndicatorWhenBusy) {
[[UIApplication sharedApplication] rk_popNetworkActivity];
[[UIApplication sharedApplication] popNetworkActivity];
}
#endif
}
@@ -490,48 +490,48 @@ static const NSTimeInterval kFlushDelay = 0.3;
@implementation UIApplication (RKNetworkActivity)
static NSInteger rk_networkActivityCount;
static NSInteger networkActivityCount;
- (NSInteger)rk_networkActivityCount {
- (NSInteger)networkActivityCount {
@synchronized(self) {
return rk_networkActivityCount;
return networkActivityCount;
}
}
- (void)rk_refreshActivityIndicator {
- (void)refreshActivityIndicator {
if(![NSThread isMainThread]) {
SEL sel_refresh = @selector(rk_refreshActivityIndicator);
SEL sel_refresh = @selector(refreshActivityIndicator);
[self performSelectorOnMainThread:sel_refresh withObject:nil waitUntilDone:NO];
return;
}
BOOL active = (self.rk_networkActivityCount > 0);
BOOL active = (self.networkActivityCount > 0);
self.networkActivityIndicatorVisible = active;
}
- (void)rk_pushNetworkActivity {
- (void)pushNetworkActivity {
@synchronized(self) {
rk_networkActivityCount++;
networkActivityCount++;
}
[self rk_refreshActivityIndicator];
[self refreshActivityIndicator];
}
- (void)rk_popNetworkActivity {
- (void)popNetworkActivity {
@synchronized(self) {
if (rk_networkActivityCount > 0) {
rk_networkActivityCount--;
if (networkActivityCount > 0) {
networkActivityCount--;
} else {
rk_networkActivityCount = 0;
networkActivityCount = 0;
RKLogError(@"Unbalanced network activity: count already 0.");
}
}
[self rk_refreshActivityIndicator];
[self refreshActivityIndicator];
}
- (void)rk_resetNetworkActivity {
- (void)resetNetworkActivity {
@synchronized(self) {
rk_networkActivityCount = 0;
networkActivityCount = 0;
}
[self rk_refreshActivityIndicator];
[self refreshActivityIndicator];
}
@end