diff --git a/Code/CoreData/NSManagedObject+ActiveRecord.m b/Code/CoreData/NSManagedObject+ActiveRecord.m index 69677286d4..fb09c4e479 100644 --- a/Code/CoreData/NSManagedObject+ActiveRecord.m +++ b/Code/CoreData/NSManagedObject+ActiveRecord.m @@ -120,7 +120,7 @@ + (void)setDefaultBatchSize:(NSUInteger)newBatchSize { @synchronized(defaultBatchSize) { - defaultBatchSize = [NSNumber numberWithInt:newBatchSize]; + defaultBatchSize = [NSNumber numberWithUnsignedInteger:newBatchSize]; } } @@ -325,7 +325,7 @@ + (NSNumber *)numberOfEntitiesWithPredicate:(NSPredicate *)searchTerm inContext: NSUInteger count = [context countForFetchRequest:request error:&error]; [self handleErrors:error]; - return [NSNumber numberWithUnsignedInt:count]; + return [NSNumber numberWithUnsignedInteger:count]; } + (NSNumber *)numberOfEntitiesWithPredicate:(NSPredicate *)searchTerm; diff --git a/Code/CoreData/RKManagedObjectMappingOperation.m b/Code/CoreData/RKManagedObjectMappingOperation.m index c3f2ce74ac..c6bf89c7bc 100644 --- a/Code/CoreData/RKManagedObjectMappingOperation.m +++ b/Code/CoreData/RKManagedObjectMappingOperation.m @@ -27,26 +27,6 @@ #undef RKLogComponent #define RKLogComponent lcl_cRestKitCoreData -/** - Progressively enhance the RKObjectMappingOperation base class to inject Core Data - specifics without leaking into the object mapper abstractions - */ -@implementation RKObjectMappingOperation (CoreData) - -/* - Trampoline the initialization through RKManagedObjectMapping so the mapper uses RKManagedObjectMappingOperation - at the right moments - */ -+ (RKObjectMappingOperation*)mappingOperationFromObject:(id)sourceObject toObject:(id)destinationObject withMapping:(RKObjectMapping*)objectMapping { - if ([objectMapping isKindOfClass:[RKManagedObjectMapping class]]) { - return [[[RKManagedObjectMappingOperation alloc] initWithSourceObject:sourceObject destinationObject:destinationObject mapping:objectMapping] autorelease]; - } - - return [[[RKObjectMappingOperation alloc] initWithSourceObject:sourceObject destinationObject:destinationObject mapping:objectMapping] autorelease]; -} - -@end - @implementation RKManagedObjectMappingOperation // TODO: Move this to a better home to take exposure out of the mapper diff --git a/Code/CoreData/RKManagedObjectSeeder.m b/Code/CoreData/RKManagedObjectSeeder.m index 5d3b5459a7..785144358b 100644 --- a/Code/CoreData/RKManagedObjectSeeder.m +++ b/Code/CoreData/RKManagedObjectSeeder.m @@ -156,7 +156,7 @@ - (void)seedObjectsFromFile:(NSString *)fileName withObjectMapping:(RKObjectMapp } } - RKLogInfo(@"Seeded %d objects from %@...", [mappedObjects count], [NSString stringWithFormat:@"%@", fileName]); + RKLogInfo(@"Seeded %lu objects from %@...", (unsigned long) [mappedObjects count], [NSString stringWithFormat:@"%@", fileName]); } else { RKLogError(@"Unable to read file %@: %@", fileName, [error localizedDescription]); } diff --git a/Code/CoreData/RKManagedObjectStore.m b/Code/CoreData/RKManagedObjectStore.m index 20a52a103c..99b99e65dd 100644 --- a/Code/CoreData/RKManagedObjectStore.m +++ b/Code/CoreData/RKManagedObjectStore.m @@ -421,7 +421,7 @@ - (NSManagedObject*)findOrCreateInstanceOfEntity:(NSEntityDescription*)entity wi [fetchRequest setEntity:entity]; [fetchRequest setReturnsObjectsAsFaults:NO]; objects = [NSManagedObject executeFetchRequest:fetchRequest]; - RKLogInfo(@"Caching all %d %@ objects to thread local storage", [objects count], entity.name); + RKLogInfo(@"Caching all %lu %@ objects to thread local storage", (unsigned long) [objects count], entity.name); NSMutableDictionary* dictionary = [NSMutableDictionary dictionary]; BOOL coerceToString = [[[objects lastObject] valueForKey:primaryKeyAttribute] respondsToSelector:@selector(stringValue)]; for (id theObject in objects) { diff --git a/Code/CoreData/RKManagedObjectThreadSafeInvocation.m b/Code/CoreData/RKManagedObjectThreadSafeInvocation.m index 9dfa1530c4..ebc2da6bca 100644 --- a/Code/CoreData/RKManagedObjectThreadSafeInvocation.m +++ b/Code/CoreData/RKManagedObjectThreadSafeInvocation.m @@ -33,7 +33,7 @@ - (void)setManagedObjectKeyPaths:(NSSet*)keyPaths forArgument:(NSInteger)index { _argumentKeyPaths = [[NSMutableDictionary alloc] init]; } - NSNumber* argumentIndex = [NSNumber numberWithInt:index]; + NSNumber* argumentIndex = [NSNumber numberWithInteger:index]; [_argumentKeyPaths setObject:keyPaths forKey:argumentIndex]; } diff --git a/Code/Network/NSData+MD5.m b/Code/Network/NSData+MD5.m index 599b4ad3f2..c6d1fa4c40 100644 --- a/Code/Network/NSData+MD5.m +++ b/Code/Network/NSData+MD5.m @@ -26,12 +26,12 @@ @implementation NSData (MD5) -- (NSString*)MD5 { +- (NSString *)MD5 { // Create byte array of unsigned chars unsigned char md5Buffer[CC_MD5_DIGEST_LENGTH]; // Create 16 byte MD5 hash value, store in buffer - CC_MD5(self.bytes, self.length, md5Buffer); + CC_MD5(self.bytes, (CC_LONG) self.length, md5Buffer); // Convert unsigned char buffer to NSString of hex values NSMutableString* output = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2]; diff --git a/Code/Network/NSString+MD5.m b/Code/Network/NSString+MD5.m index 011ab2864c..e2f182d098 100644 --- a/Code/Network/NSString+MD5.m +++ b/Code/Network/NSString+MD5.m @@ -34,7 +34,7 @@ - (NSString*)MD5 { unsigned char md5Buffer[CC_MD5_DIGEST_LENGTH]; // Create 16 byte MD5 hash value, store in buffer - CC_MD5(ptr, strlen(ptr), md5Buffer); + CC_MD5(ptr, (CC_LONG) strlen(ptr), md5Buffer); // Convert MD5 value in the buffer to NSString of hex values NSMutableString* output = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2]; diff --git a/Code/Network/RKRequest.m b/Code/Network/RKRequest.m index 5f6280b8e4..985e8cb030 100644 --- a/Code/Network/RKRequest.m +++ b/Code/Network/RKRequest.m @@ -559,7 +559,7 @@ - (void)didFinishLoad:(RKResponse*)response { _isLoading = NO; _isLoaded = YES; - RKLogInfo(@"Status Code: %d", [response statusCode]); + RKLogInfo(@"Status Code: %ld", (long) [response statusCode]); RKLogInfo(@"Body: %@", [response bodyAsString]); RKResponse* finalResponse = response; diff --git a/Code/Network/RKRequestCache.m b/Code/Network/RKRequestCache.m index 11c5193038..9485245584 100644 --- a/Code/Network/RKRequestCache.m +++ b/Code/Network/RKRequestCache.m @@ -189,7 +189,7 @@ - (void)storeResponse:(RKResponse*)response forRequest:(RKRequest*)request { [headers setObject:[[RKRequestCache rfc1123DateFormatter] stringFromDate:[NSDate date]] forKey:cacheDateHeaderKey]; // Cache status code - [headers setObject:[NSNumber numberWithInt:urlResponse.statusCode] + [headers setObject:[NSNumber numberWithInteger:urlResponse.statusCode] forKey:cacheResponseCodeKey]; // Cache MIME Type [headers setObject:urlResponse.MIMEType diff --git a/Code/Network/RKRequestQueue.m b/Code/Network/RKRequestQueue.m index 7824fd770c..a2ec1ee390 100644 --- a/Code/Network/RKRequestQueue.m +++ b/Code/Network/RKRequestQueue.m @@ -186,7 +186,7 @@ - (NSString*)description { - (void)setLoadingCount:(NSUInteger)count { if (_loadingCount == 0 && count > 0) { - RKLogTrace(@"Loading count increasing from 0 to %d. Firing requestQueueDidBeginLoading", count); + RKLogTrace(@"Loading count increasing from 0 to %ld. Firing requestQueueDidBeginLoading", (long) count); // Transitioning from empty to processing if ([_delegate respondsToSelector:@selector(requestQueueDidBeginLoading:)]) { @@ -199,7 +199,7 @@ - (void)setLoadingCount:(NSUInteger)count { } #endif } else if (_loadingCount > 0 && count == 0) { - RKLogTrace(@"Loading count decreasing from %d to 0. Firing requestQueueDidFinishLoading", _loadingCount); + RKLogTrace(@"Loading count decreasing from %ld to 0. Firing requestQueueDidFinishLoading", (long) _loadingCount); // Transition from processing to empty if ([_delegate respondsToSelector:@selector(requestQueueDidFinishLoading:)]) { @@ -213,7 +213,7 @@ - (void)setLoadingCount:(NSUInteger)count { #endif } - RKLogTrace(@"Loading count set to %d for queue %@", count, self); + RKLogTrace(@"Loading count set to %ld for queue %@", (long) count, self); _loadingCount = count; } @@ -268,8 +268,8 @@ - (void)loadNextInQueue { } self.loadingCount = self.loadingCount + 1; - [request sendAsynchronously]; - RKLogDebug(@"Sent request %@ from queue %@. Loading count = %d of %d", request, self, self.loadingCount, _concurrentRequestsLimit); + [request sendAsynchronously]; + RKLogDebug(@"Sent request %@ from queue %@. Loading count = %ld of %ld", request, self, (long) self.loadingCount, (long) _concurrentRequestsLimit); if ([_delegate respondsToSelector:@selector(requestQueue:didSendRequest:)]) { [_delegate requestQueue:self didSendRequest:request]; @@ -349,7 +349,7 @@ - (BOOL)removeRequest:(RKRequest*)request decrementCounter:(BOOL)decrementCounte if (decrementCounter) { NSAssert(self.loadingCount > 0, @"Attempted to decrement loading count below zero"); self.loadingCount = self.loadingCount - 1; - RKLogTrace(@"Decremented the loading count to %d", self.loadingCount); + RKLogTrace(@"Decremented the loading count to %ld", (long) self.loadingCount); } return YES; } @@ -440,7 +440,7 @@ - (void)requestFinishedWithNotification:(NSNotification*)notification { if ([notification.name isEqualToString:RKRequestDidLoadResponseNotification]) { // We successfully loaded a response - RKLogDebug(@"Received response for request %@, removing from queue. (Now loading %d of %d)", request, _loadingCount, _concurrentRequestsLimit); + RKLogDebug(@"Received response for request %@, removing from queue. (Now loading %lu of %lu)", request, (unsigned long) _loadingCount, (unsigned long) _concurrentRequestsLimit); RKResponse* response = [userInfo objectForKey:RKRequestDidLoadResponseNotificationUserInfoResponseKey]; if ([_delegate respondsToSelector:@selector(requestQueue:didLoadResponse:)]) { @@ -451,8 +451,8 @@ - (void)requestFinishedWithNotification:(NSNotification*)notification { NSError* error = nil; if (userInfo) { error = [userInfo objectForKey:RKRequestDidFailWithErrorNotificationUserInfoErrorKey]; - RKLogDebug(@"Request %@ failed loading in queue %@ with error: %@.(Now loading %d of %d)", request, self, - [error localizedDescription], _loadingCount, _concurrentRequestsLimit); + RKLogDebug(@"Request %@ failed loading in queue %@ with error: %@.(Now loading %ld of %ld)", request, self, + [error localizedDescription], (long) _loadingCount, (long) _concurrentRequestsLimit); } else { RKLogWarning(@"Received RKRequestDidFailWithErrorNotification without a userInfo, something is amiss..."); } diff --git a/Code/Network/RKResponse.m b/Code/Network/RKResponse.m index a543322d05..ab3f21a944 100644 --- a/Code/Network/RKResponse.m +++ b/Code/Network/RKResponse.m @@ -151,7 +151,7 @@ - (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallen [[challenge sender] useCredential:newCredential forAuthenticationChallenge:challenge]; } else { - RKLogWarning(@"Failed authentication challenge after %d failures", [challenge previousFailureCount]); + RKLogWarning(@"Failed authentication challenge after %ld failures", (long) [challenge previousFailureCount]); [[challenge sender] cancelAuthenticationChallenge:challenge]; } } @@ -186,7 +186,7 @@ - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { } - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSHTTPURLResponse *)response { - RKLogDebug(@"NSHTTPURLResponse Status Code: %d", [response statusCode]); + RKLogDebug(@"NSHTTPURLResponse Status Code: %ld", (long) [response statusCode]); RKLogDebug(@"Headers: %@", [response allHeaderFields]); _httpURLResponse = [response retain]; } diff --git a/Code/ObjectMapping/RKObjectLoader.m b/Code/ObjectMapping/RKObjectLoader.m index 8b29275101..5a401d66fc 100644 --- a/Code/ObjectMapping/RKObjectLoader.m +++ b/Code/ObjectMapping/RKObjectLoader.m @@ -260,7 +260,7 @@ - (BOOL)isResponseMappable { return NO; } else if (NO == [self canParseMIMEType:[self.response MIMEType]]) { // We can't parse the response, it's unmappable regardless of the status code - RKLogWarning(@"Encountered unexpected response with status code: %d (MIME Type: %@)", self.response.statusCode, self.response.MIMEType); + RKLogWarning(@"Encountered unexpected response with status code: %ld (MIME Type: %@)", (long) self.response.statusCode, self.response.MIMEType); NSError* error = [NSError errorWithDomain:RKRestKitErrorDomain code:RKObjectLoaderUnexpectedResponseError userInfo:nil]; if ([_delegate respondsToSelector:@selector(objectLoaderDidLoadUnexpectedResponse:)]) { [(NSObject*)_delegate objectLoaderDidLoadUnexpectedResponse:self]; diff --git a/Code/ObjectMapping/RKObjectMappingOperation.h b/Code/ObjectMapping/RKObjectMappingOperation.h index 0f27b067cb..b1edaee0da 100644 --- a/Code/ObjectMapping/RKObjectMappingOperation.h +++ b/Code/ObjectMapping/RKObjectMappingOperation.h @@ -81,9 +81,13 @@ /** Create a new mapping operation configured to transform the object representation - in a source object to a new destination object according to an object mapping definition + in a source object to a new destination object according to an object mapping definition. + + Note that if Core Data support is available, an instance of RKManagedObjectMappingOperation may be returned + + @return An instance of RKObjectMappingOperation or RKManagedObjectMappingOperation for performing the mapping */ -+ (RKObjectMappingOperation*)mappingOperationFromObject:(id)sourceObject toObject:(id)destinationObject withMapping:(id)mapping; ++ (id)mappingOperationFromObject:(id)sourceObject toObject:(id)destinationObject withMapping:(id)mapping; /** Initialize a mapping operation for an object and set of data at a particular key path with an object mapping definition diff --git a/Code/ObjectMapping/RKObjectMappingOperation.m b/Code/ObjectMapping/RKObjectMappingOperation.m index 28823ad518..8135d0f150 100644 --- a/Code/ObjectMapping/RKObjectMappingOperation.m +++ b/Code/ObjectMapping/RKObjectMappingOperation.m @@ -70,8 +70,12 @@ @implementation RKObjectMappingOperation @synthesize delegate = _delegate; @synthesize queue = _queue; -+ (RKObjectMappingOperation*)mappingOperationFromObject:(id)sourceObject toObject:(id)destinationObject withMapping:(id)objectMapping { - return [[[self alloc] initWithSourceObject:sourceObject destinationObject:destinationObject mapping:objectMapping] autorelease]; ++ (id)mappingOperationFromObject:(id)sourceObject toObject:(id)destinationObject withMapping:(id)objectMapping { + // Check for availability of ManagedObjectMappingOperation. Better approach for handling? + Class targetClass = NSClassFromString(@"RKManagedObjectMappingOperation"); + if (targetClass == nil) targetClass = [RKObjectMappingOperation class]; + + return [[[targetClass alloc] initWithSourceObject:sourceObject destinationObject:destinationObject mapping:objectMapping] autorelease]; } - (id)initWithSourceObject:(id)sourceObject destinationObject:(id)destinationObject mapping:(id)objectMapping { diff --git a/Code/ObjectMapping/RKObjectMappingResult.m b/Code/ObjectMapping/RKObjectMappingResult.m index 19add16215..d8269db201 100644 --- a/Code/ObjectMapping/RKObjectMappingResult.m +++ b/Code/ObjectMapping/RKObjectMappingResult.m @@ -69,7 +69,7 @@ - (id)asObject { return nil; } - if (count > 1) RKLogWarning(@"Coerced object mapping result containing %d objects into singular result.", count); + if (count > 1) RKLogWarning(@"Coerced object mapping result containing %lu objects into singular result.", (unsigned long) count); return [collection objectAtIndex:0]; } diff --git a/Code/Support/Parsers/XML/RKXMLParserLibXML.m b/Code/Support/Parsers/XML/RKXMLParserLibXML.m index 2bbeb949a4..f24d90024c 100644 --- a/Code/Support/Parsers/XML/RKXMLParserLibXML.m +++ b/Code/Support/Parsers/XML/RKXMLParserLibXML.m @@ -123,7 +123,7 @@ - (NSDictionary*)parseXML:(NSString*)xml { } /* Parse the string. */ const char* buffer = [xml cStringUsingEncoding:NSUTF8StringEncoding]; - doc = xmlParseMemory(buffer, strlen(buffer)); + doc = xmlParseMemory(buffer, (int) strlen(buffer)); /* check if parsing suceeded */ if (doc == NULL) { diff --git a/Vendor/SOCKit/SOCKit.m b/Vendor/SOCKit/SOCKit.m index aca5e38bb9..70c226b7eb 100644 --- a/Vendor/SOCKit/SOCKit.m +++ b/Vendor/SOCKit/SOCKit.m @@ -359,7 +359,7 @@ - (void)setArgumentsFromValues:(NSArray *)values forInvocation:(NSInvocation *)i NSString* value = [values objectAtIndex:ix]; char argType[4]; - method_getArgumentType(method, ix + 2, argType, sizeof(argType) / sizeof(argType[0])); + method_getArgumentType(method, (unsigned int) ix + 2, argType, sizeof(argType) / sizeof(argType[0])); SOCArgumentType type = SOCArgumentTypeForTypeAsChar(argType[0]); [self setArgument:value withType:type atIndex:ix forInvocation:invocation];