From 479864902bf228ee1ecbcb9cb87e61714b3d299d Mon Sep 17 00:00:00 2001 From: Blake Watters Date: Thu, 8 Dec 2011 23:23:20 -0500 Subject: [PATCH] Fixed all build warnings on OS X Framework target --- Code/CoreData/NSManagedObject+ActiveRecord.m | 4 ++-- .../RKManagedObjectMappingOperation.m | 20 ------------------- Code/CoreData/RKManagedObjectSeeder.m | 2 +- Code/CoreData/RKManagedObjectStore.m | 2 +- .../RKManagedObjectThreadSafeInvocation.m | 2 +- Code/Network/NSData+MD5.m | 4 ++-- Code/Network/NSString+MD5.m | 2 +- Code/Network/RKRequest.m | 2 +- Code/Network/RKRequestCache.m | 2 +- Code/Network/RKRequestQueue.m | 18 ++++++++--------- Code/Network/RKResponse.m | 4 ++-- Code/ObjectMapping/RKObjectLoader.m | 2 +- Code/ObjectMapping/RKObjectMappingOperation.h | 8 ++++++-- Code/ObjectMapping/RKObjectMappingOperation.m | 8 ++++++-- Code/ObjectMapping/RKObjectMappingResult.m | 2 +- Code/Support/Parsers/XML/RKXMLParserLibXML.m | 2 +- Vendor/SOCKit/SOCKit.m | 2 +- 17 files changed, 37 insertions(+), 49 deletions(-) diff --git a/Code/CoreData/NSManagedObject+ActiveRecord.m b/Code/CoreData/NSManagedObject+ActiveRecord.m index 69677286..fb09c4e4 100644 --- a/Code/CoreData/NSManagedObject+ActiveRecord.m +++ b/Code/CoreData/NSManagedObject+ActiveRecord.m @@ -120,7 +120,7 @@ static NSNumber *defaultBatchSize = nil; { @synchronized(defaultBatchSize) { - defaultBatchSize = [NSNumber numberWithInt:newBatchSize]; + defaultBatchSize = [NSNumber numberWithUnsignedInteger:newBatchSize]; } } @@ -325,7 +325,7 @@ static NSNumber *defaultBatchSize = nil; 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 c3f2ce74..c6bf89c7 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 5d3b5459..78514435 100644 --- a/Code/CoreData/RKManagedObjectSeeder.m +++ b/Code/CoreData/RKManagedObjectSeeder.m @@ -156,7 +156,7 @@ NSString* const RKDefaultSeedDatabaseFileName = @"RKSeedDatabase.sqlite"; } } - 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 20a52a10..99b99e65 100644 --- a/Code/CoreData/RKManagedObjectStore.m +++ b/Code/CoreData/RKManagedObjectStore.m @@ -421,7 +421,7 @@ static NSString* const RKManagedObjectStoreThreadDictionaryEntityCacheKey = @"RK [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 9dfa1530..ebc2da6b 100644 --- a/Code/CoreData/RKManagedObjectThreadSafeInvocation.m +++ b/Code/CoreData/RKManagedObjectThreadSafeInvocation.m @@ -33,7 +33,7 @@ _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 599b4ad3..c6d1fa4c 100644 --- a/Code/Network/NSData+MD5.m +++ b/Code/Network/NSData+MD5.m @@ -26,12 +26,12 @@ RK_FIX_CATEGORY_BUG(NSData_MD5) @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 011ab286..e2f182d0 100644 --- a/Code/Network/NSString+MD5.m +++ b/Code/Network/NSString+MD5.m @@ -34,7 +34,7 @@ RK_FIX_CATEGORY_BUG(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 5f6280b8..985e8cb0 100644 --- a/Code/Network/RKRequest.m +++ b/Code/Network/RKRequest.m @@ -559,7 +559,7 @@ _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 11c51930..94852455 100644 --- a/Code/Network/RKRequestCache.m +++ b/Code/Network/RKRequestCache.m @@ -189,7 +189,7 @@ static NSDateFormatter* __rfc1123DateFormatter; [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 7824fd77..a2ec1ee3 100644 --- a/Code/Network/RKRequestQueue.m +++ b/Code/Network/RKRequestQueue.m @@ -186,7 +186,7 @@ static const NSTimeInterval kFlushDelay = 0.3; - (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 @@ static const NSTimeInterval kFlushDelay = 0.3; } #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 @@ static const NSTimeInterval kFlushDelay = 0.3; #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 @@ static const NSTimeInterval kFlushDelay = 0.3; } 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 @@ static const NSTimeInterval kFlushDelay = 0.3; 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 @@ static const NSTimeInterval kFlushDelay = 0.3; 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 @@ static const NSTimeInterval kFlushDelay = 0.3; 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 a543322d..ab3f21a9 100644 --- a/Code/Network/RKResponse.m +++ b/Code/Network/RKResponse.m @@ -151,7 +151,7 @@ extern NSString* cacheURLKey; [[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 @@ extern NSString* cacheURLKey; } - (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 8b292751..5a401d66 100644 --- a/Code/ObjectMapping/RKObjectLoader.m +++ b/Code/ObjectMapping/RKObjectLoader.m @@ -260,7 +260,7 @@ 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 0f27b067..b1edaee0 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 28823ad5..8135d0f1 100644 --- a/Code/ObjectMapping/RKObjectMappingOperation.m +++ b/Code/ObjectMapping/RKObjectMappingOperation.m @@ -70,8 +70,12 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) { @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 19add162..d8269db2 100644 --- a/Code/ObjectMapping/RKObjectMappingResult.m +++ b/Code/ObjectMapping/RKObjectMappingResult.m @@ -69,7 +69,7 @@ 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 2bbeb949..f24d9002 100644 --- a/Code/Support/Parsers/XML/RKXMLParserLibXML.m +++ b/Code/Support/Parsers/XML/RKXMLParserLibXML.m @@ -123,7 +123,7 @@ } /* 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 aca5e38b..70c226b7 100644 --- a/Vendor/SOCKit/SOCKit.m +++ b/Vendor/SOCKit/SOCKit.m @@ -359,7 +359,7 @@ NSString* kTemporaryBackslashToken = @"/backslash/"; 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];