diff --git a/OpenKit.xcodeproj/project.pbxproj b/OpenKit.xcodeproj/project.pbxproj index 677685c..4cc3229 100644 --- a/OpenKit.xcodeproj/project.pbxproj +++ b/OpenKit.xcodeproj/project.pbxproj @@ -1169,6 +1169,7 @@ ); GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "OpenKit-Prefix.pch"; + ONLY_ACTIVE_ARCH = NO; OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; diff --git a/OpenKit/KGModal.h b/OpenKit/KGModal.h index 8516a40..1435725 100644 --- a/OpenKit/KGModal.h +++ b/OpenKit/KGModal.h @@ -8,7 +8,7 @@ #import -NS_ENUM(NSUInteger, KGModalBackgroundDisplayStyle){ +typedef NS_ENUM(NSUInteger, KGModalBackgroundDisplayStyle){ KGModalBackgroundDisplayStyleGradient, KGModalBackgroundDisplayStyleSolid }; @@ -37,7 +37,7 @@ NS_ENUM(NSUInteger, KGModalBackgroundDisplayStyle){ // The background display style, can be a transparent radial gradient or a transparent black // Defaults to gradient, this looks better but takes a bit more time to display on the retina iPad -@property (nonatomic) enum KGModalBackgroundDisplayStyle backgroundDisplayStyle; +@property (nonatomic) KGModalBackgroundDisplayStyle backgroundDisplayStyle; // Determins if the modal should rotate when the device rotates // Defaults to YES, only applies to iOS5 diff --git a/OpenKit/KGModal.m b/OpenKit/KGModal.m index 768feec..729f547 100644 --- a/OpenKit/KGModal.m +++ b/OpenKit/KGModal.m @@ -91,7 +91,9 @@ - (void)showWithContentView:(UIView *)contentView andAnimated:(BOOL)animated{ containerView.modalBackgroundColor = self.modalBackgroundColor; containerView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin| UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleBottomMargin; +#if !defined(ANDROID) containerView.layer.rasterizationScale = [[UIScreen mainScreen] scale]; +#endif contentView.frame = (CGRect){padding, padding, contentView.bounds.size}; [containerView addSubview:contentView]; [viewController.view addSubview:containerView]; @@ -118,7 +120,9 @@ - (void)showWithContentView:(UIView *)contentView andAnimated:(BOOL)animated{ }]; containerView.alpha = 0; +#if !defined(ANDROID) containerView.layer.shouldRasterize = YES; +#endif containerView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.4, 0.4); [UIView animateWithDuration:kTransformPart1AnimationDuration animations:^{ containerView.alpha = 1; @@ -128,7 +132,9 @@ - (void)showWithContentView:(UIView *)contentView andAnimated:(BOOL)animated{ containerView.alpha = 1; containerView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1, 1); } completion:^(BOOL finished2) { +#if !defined(ANDROID) containerView.layer.shouldRasterize = NO; +#endif }]; }]; } @@ -167,8 +173,9 @@ - (void)hideAnimated:(BOOL)animated withCompletionBlock:(void(^)())completion{ [UIView animateWithDuration:kFadeInAnimationDuration animations:^{ self.viewController.styleView.alpha = 0; }]; - +#if !defined(ANDROID) self.containerView.layer.shouldRasterize = YES; +#endif [UIView animateWithDuration:kTransformPart2AnimationDuration animations:^{ self.containerView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.1, 1.1); } completion:^(BOOL finished){ diff --git a/OpenKit/OKAchievementsViewController.m b/OpenKit/OKAchievementsViewController.m index 35977fa..1250d54 100644 --- a/OpenKit/OKAchievementsViewController.m +++ b/OpenKit/OKAchievementsViewController.m @@ -22,7 +22,11 @@ -(id)init { if(self) { OKAchievementsListVC *achievementsVC = [[OKAchievementsListVC alloc] init]; NSArray *viewControllers = [NSArray arrayWithObject:achievementsVC]; +#if defined(ANDROID) + [self setViewControllers:viewControllers]; +#else [self setViewControllers:viewControllers animated:NO]; +#endif UITabBarItem *tabBarItem = [[UITabBarItem alloc] initWithTitle:@"Achievements" image:[UIImage imageNamed:@"achievements.png"] tag:2]; [self setTabBarItem:tabBarItem]; diff --git a/OpenKit/OKBaseLoginViewController.h b/OpenKit/OKBaseLoginViewController.h index c6eb342..8126513 100644 --- a/OpenKit/OKBaseLoginViewController.h +++ b/OpenKit/OKBaseLoginViewController.h @@ -18,9 +18,16 @@ @interface OKBaseLoginViewController : UIViewController - - +#if defined(ANDROID) +{ + UIWindow *_window; +} + +-(void) setWindow:(UIWindow *)window; +-(UIWindow*) window; +#else @property (nonatomic, strong) UIWindow *window; +#endif @property (nonatomic, strong) UIActivityIndicatorView *spinner; @property (nonatomic, strong) UIView *loginView; @property (nonatomic, strong) id delegate; diff --git a/OpenKit/OKBaseLoginViewController.m b/OpenKit/OKBaseLoginViewController.m index e106d32..20e57da 100644 --- a/OpenKit/OKBaseLoginViewController.m +++ b/OpenKit/OKBaseLoginViewController.m @@ -26,6 +26,17 @@ @interface OKBaseLoginViewController () @implementation OKBaseLoginViewController @synthesize loginView,spinner, fbLoginButton, gcLoginButton, delegate, loginString; +#if defined(ANDROID) +-(void) setWindow:(UIWindow *)window +{ + _window = window; +} + +-(UIWindow*) window +{ + return _window; +} +#endif -(id)initWithLoginString:(NSString*)aLoginString { diff --git a/OpenKit/OKLeaderboard.h b/OpenKit/OKLeaderboard.h index da7cd94..5acb395 100644 --- a/OpenKit/OKLeaderboard.h +++ b/OpenKit/OKLeaderboard.h @@ -54,6 +54,8 @@ typedef enum { //Wrapper methods -(void)getGlobalScoresWithPageNum:(int)pageNum withCompletionHandler:(void (^)(NSArray *scores, NSError *error))completionHandler; -(void)getPlayerTopScoreWithCompletionHandler:(void (^)(id score, NSError *error))completionHandler; +-(void)getPlayerGlobalTopScoreWithCompletionHandler:(void (^)(id score))completionHandler; +-(void) getAllPlayerScoresWithCompletionHandler:(void (^)(NSArray *scores))completionHandler; //GameCenter methods -(void)getGameCenterFriendsScoreswithCompletionHandler:(void (^)(NSArray *scores, NSError *error))completionHandler; diff --git a/OpenKit/OKLeaderboard.m b/OpenKit/OKLeaderboard.m index 1cf1f7d..ca2f632 100644 --- a/OpenKit/OKLeaderboard.m +++ b/OpenKit/OKLeaderboard.m @@ -30,14 +30,17 @@ - (id)initFromJSON:(NSDictionary*)jsonDict { if ((self = [super init])) { NSString *sortTypeString = [OKHelper getNSStringSafeForKey:@"sort_type" fromJSONDictionary:jsonDict]; - self.name = [OKHelper getNSStringSafeForKey:@"name" fromJSONDictionary:jsonDict]; self.OKLeaderboard_id = [[OKHelper getNSNumberSafeForKey:@"id" fromJSONDictionary:jsonDict] integerValue]; self.OKApp_id = [[OKHelper getNSNumberSafeForKey:@"app_id" fromJSONDictionary:jsonDict] integerValue]; self.sortType = ([sortTypeString isEqualToString:@"HighValue"]) ? OKLeaderboardSortTypeHighValue : OKLeaderboardSortTypeLowValue; self.icon_url = [OKHelper getNSStringSafeForKey:@"icon_url" fromJSONDictionary:jsonDict]; self.playerCount = [[OKHelper getNSNumberSafeForKey:@"player_count" fromJSONDictionary:jsonDict] integerValue]; +#if defined(ANDROID) + self.gamecenter_id = [OKHelper getNSStringSafeForKey:@"gpg_id" fromJSONDictionary:jsonDict]; +#else self.gamecenter_id = [OKHelper getNSStringSafeForKey:@"gamecenter_id" fromJSONDictionary:jsonDict]; +#endif } return self; @@ -65,6 +68,7 @@ + (void)getLeaderboardsWithCompletionHandler:(void (^)(NSArray* leaderboards, in + (void)getLeaderboardsWithTag:(NSString*)leaderbaordListTag WithCompletionHandler:(void (^)(NSArray* leaderboards, int playerCount, NSError* error))completionHandler { + NSDictionary *requestParams = [NSDictionary dictionaryWithObject:leaderbaordListTag forKey:@"tag"]; // OK NETWORK REQUEST @@ -168,7 +172,6 @@ -(void)getGameCenterFriendsScoreswithCompletionHandler:(void (^)(NSArray *scores -(void)getScoresFromGameCenterWithRange:(NSRange)scoreRange withPlayerScope:(GKLeaderboardPlayerScope)playerScope withCompletionHandler:(void (^)(NSArray *scores, NSError *error))completionHandler { GKLeaderboard *leaderboardRequest = [[GKLeaderboard alloc] init]; - if(![self gamecenter_id]) { completionHandler(nil, [OKError noGameCenterIDError]); return; @@ -363,6 +366,68 @@ -(void)getPlayerTopScoreWithCompletionHandler:(void (^)(id scor } } +-(void)getPlayerGlobalTopScoreWithCompletionHandler:(void (^)(id score))completionHandler +{ + // This function returns the global best score, preferring facebook -> game center -> cached // + + NSMutableArray *scores = [NSMutableArray arrayWithCapacity:3]; + + // the order in which you add the scores affects the priority of the result when they have equal values // + [self getPlayerTopScoreForLeaderboardForTimeRange:OKLeaderboardTimeRangeAllTime withCompletionHandler:^(OKScore *okScore, NSError *okError) { // OK SCORE // + if (!okError && okScore) + { + [scores addObject:okScore]; + } + [self getPlayerTopScoreFromGameCenterWithCompletionHandler:^(OKGKScoreWrapper *gcScore, NSError *gamecenterError) { // GAME CENTER // + if (!gamecenterError && gcScore) + { + [scores addObject:gcScore]; + } + + OKScore *topCachedScore = [self getPlayerTopScoreFromLocalCache]; // CACHED // + if (topCachedScore) + { + [scores addObject:topCachedScore]; + } + + // sort the scores and call the completion handler // + id bestScore = nil; + NSArray *sorted = [self sortScoresBasedOnLeaderboardType:scores]; + bestScore = [sorted firstObject]; + completionHandler(bestScore); + }]; + }]; +} + +-(void) getAllPlayerScoresWithCompletionHandler:(void (^)(NSArray *scores))completionHandler +{ + // This function returns all the player scores so devs can check for discrepancies // + + NSMutableArray *scores = [NSMutableArray arrayWithCapacity:3]; + + // the order in which you add the scores affects the priority of the result when they have equal values // + [self getPlayerTopScoreForLeaderboardForTimeRange:OKLeaderboardTimeRangeAllTime withCompletionHandler:^(OKScore *okScore, NSError *okError) { // OK SCORE // + if (!okError && okScore) + { + [scores addObject:okScore]; + } + [self getPlayerTopScoreFromGameCenterWithCompletionHandler:^(OKGKScoreWrapper *gcScore, NSError *gamecenterError) { // GAME CENTER // + if (!gamecenterError && gcScore) + { + [scores addObject:gcScore]; + } + + OKScore *topCachedScore = [self getPlayerTopScoreFromLocalCache]; // CACHED // + if (topCachedScore) + { + [scores addObject:topCachedScore]; + } + + completionHandler(scores); + }]; + }]; +} + -(OKScore*)getPlayerTopScoreFromLocalCache { NSArray *cachedScores = [[OKScoreDB sharedCache] getCachedScoresForLeaderboardID:[self OKLeaderboard_id] andOnlyGetSubmittedScores:NO]; diff --git a/OpenKit/OKLeaderboardsViewController.m b/OpenKit/OKLeaderboardsViewController.m index a1b9046..2353666 100644 --- a/OpenKit/OKLeaderboardsViewController.m +++ b/OpenKit/OKLeaderboardsViewController.m @@ -30,7 +30,11 @@ - (id)init { self.modalPresentationStyle = UIModalPresentationFormSheet; OKLeaderboardsListViewController *list = [[OKLeaderboardsListViewController alloc]initWithDefaultLeaderboardID:defaultLeaderboardID]; NSArray *viewControllers = [NSArray arrayWithObject:list]; +#if defined(ANDROID) + [self setViewControllers:viewControllers]; +#else [self setViewControllers:viewControllers animated:NO]; +#endif UITabBarItem *tabBarItem = [[UITabBarItem alloc] initWithTitle:@"Leaderboards" image:[UIImage imageNamed:@"leaderboards.png"] tag:1]; [self setTabBarItem:tabBarItem]; diff --git a/OpenKit/OKLocalCache.h b/OpenKit/OKLocalCache.h index cc876ee..0ac2628 100644 --- a/OpenKit/OKLocalCache.h +++ b/OpenKit/OKLocalCache.h @@ -43,7 +43,7 @@ extern dispatch_queue_t __OKCacheQueue; // You can use this for insert/update/delete without access block. Selects should // go through access block so FMResultSet access is contained. -- (BOOL)update:(NSString *)sql, ...; +- (BOOL)update:(NSString *)sql, ... NS_REQUIRES_NIL_TERMINATION; // Get the autoincrement primary key int ID of the last inserted row -(int)lastInsertRowID; diff --git a/OpenKit/OKLocalCache.m b/OpenKit/OKLocalCache.m index 70a3cc2..5840267 100644 --- a/OpenKit/OKLocalCache.m +++ b/OpenKit/OKLocalCache.m @@ -46,15 +46,23 @@ -(void)access:(void(^)(FMDatabase *))block } } -- (BOOL)update:(NSString *)sql, ... +- (BOOL)update:(NSString *)sql, ... NS_REQUIRES_NIL_TERMINATION { va_list args; va_start(args, sql); + + NSMutableArray *argArray = [NSMutableArray array]; + id obj = nil; + while((obj = va_arg(args, id))) + { + [argArray addObject:obj]; + } + va_end(args); __block BOOL success; [self access:^(FMDatabase *db) { OKLogInfo(@"Performing cache update: %@", sql); - success = [db executeUpdate:sql error:nil withArgumentsInArray:nil orDictionary:nil orVAList:args]; + success = [db executeUpdate:sql error:nil withArgumentsInArray:argArray orDictionary:nil orVAList:nil]; OKLogInfo(@"...%@", (success ? @"success" : @"FAIL")); // We have to cache the last inserted row ID because @@ -63,7 +71,6 @@ - (BOOL)update:(NSString *)sql, ... lastInsertRowID = [db lastInsertRowId]; } }]; - va_end(args); return success; } @@ -139,7 +146,7 @@ -(void)sanity - (BOOL)insertToken:(NSString *)tokenStr { NSDate *now = [NSDate date]; - return [self update:@"insert into tokens (token, submitted, created_at) values (?, ?, ?) ", tokenStr, [NSNumber numberWithInt:0], now]; + return [self update:@"insert into tokens (token, submitted, created_at) values (?, ?, ?) ", tokenStr, [NSNumber numberWithInt:0], now, nil]; } diff --git a/OpenKit/OKManager.m b/OpenKit/OKManager.m index dd103ec..214c778 100644 --- a/OpenKit/OKManager.m +++ b/OpenKit/OKManager.m @@ -20,7 +20,7 @@ #import "OKSessionDb.h" #import "OKMacros.h" -#define OK_DEFAULT_ENDPOINT @"http://api.openkit.io" +#define OK_DEFAULT_ENDPOINT @"http://api.gameeso.com" #define OK_OPENKIT_SDK_VERSION = @"1.1"; static NSString *OK_USER_KEY = @"OKUserInfo"; @@ -205,12 +205,14 @@ + (void)handleWillTerminate - (void)registerToken:(NSData *)deviceToken { OKLog(@"OKManager registerToken, data: %@", deviceToken); - const unsigned *tokenBytes = [deviceToken bytes]; NSString *hexToken = [NSString stringWithFormat:@"%08x%08x%08x%08x%08x%08x%08x%08x", ntohl(tokenBytes[0]), ntohl(tokenBytes[1]), ntohl(tokenBytes[2]), ntohl(tokenBytes[3]), ntohl(tokenBytes[4]), ntohl(tokenBytes[5]), ntohl(tokenBytes[6]), ntohl(tokenBytes[7])]; +#if defined(ANDROID) + #undef ntohl +#endif OKLogInfo(@"cache queue is %s", dispatch_queue_get_label(OK_CACHE_QUEUE())); dispatch_async(OK_CACHE_QUEUE(), ^{ diff --git a/OpenKit/OKScoreDB.m b/OpenKit/OKScoreDB.m index 0e9ca18..29a26a7 100644 --- a/OpenKit/OKScoreDB.m +++ b/OpenKit/OKScoreDB.m @@ -60,7 +60,8 @@ -(void)insertScore:(OKScore*)score [NSNumber numberWithLongLong:score.scoreValue], [NSNumber numberWithInt:score.metadata], score.displayString, - [NSNumber numberWithBool:score.submitted]]; + [NSNumber numberWithBool:score.submitted], + nil]; if(inserted) { int scoreID = [self lastInsertRowID]; @@ -83,7 +84,7 @@ -(void)deleteScore:(OKScore*)score NSString *deleteSQL = @"DELETE FROM OKCACHE WHERE id=?"; - BOOL deleted = [self update:deleteSQL,[NSNumber numberWithInt:[score OKScoreID]]]; + BOOL deleted = [self update:deleteSQL,[NSNumber numberWithInt:[score OKScoreID]], nil]; if(deleted) { OKLogInfo(@"Removed score: %@", score); @@ -101,7 +102,7 @@ -(void)updateCachedScoreSubmitted:(OKScore*)score NSString *updateString = @"UPDATE OKCACHE SET Submitted=1 WHERE id=?"; - BOOL updated = [self update:updateString, [NSNumber numberWithInt:[score OKScoreID]]]; + BOOL updated = [self update:updateString, [NSNumber numberWithInt:[score OKScoreID]], nil]; if(!updated) { OKLog(@"Failed to update score row with error message %@", [self lastErrorMessage]); @@ -210,7 +211,7 @@ -(void)clearCachedSubmittedScores NSString *deleteSQL = @"DELETE FROM OKCACHE WHERE submitted=1"; - BOOL success = [self update:deleteSQL]; + BOOL success = [self update:deleteSQL, nil]; if(success) { OKLogInfo(@"Cleared all cached submitted scores"); diff --git a/OpenKit/OKSessionDb.m b/OpenKit/OKSessionDb.m index 1c278a1..662e5bd 100644 --- a/OpenKit/OKSessionDb.m +++ b/OpenKit/OKSessionDb.m @@ -166,7 +166,7 @@ - (OKSessionRow *)lastRow - (OKSessionRow *)insertRow:(OKSessionTemplate *)t { NSDate *now = [NSDate date]; - if (![self update:@"insert into sessions (uuid, fb_id, google_id, custom_id, ok_id, push_token, client_created_at) values (?, ?, ?, ?, ?, ?, ?) ", t.uuid, t.fbId, t.googleId, t.customId, t.okId, t.pushToken, now]) { + if (![self update:@"insert into sessions (uuid, fb_id, google_id, custom_id, ok_id, push_token, client_created_at) values (?, ?, ?, ?, ?, ?, ?) ", t.uuid, t.fbId, t.googleId, t.customId, t.okId, t.pushToken, now, nil]) { OKLogErr(@"Could not create new session."); return nil; } diff --git a/OpenKit/Vendor/fmdb-fd95c38/FMDatabase.h b/OpenKit/Vendor/fmdb-fd95c38/FMDatabase.h index 32b7783..1455a4a 100644 --- a/OpenKit/Vendor/fmdb-fd95c38/FMDatabase.h +++ b/OpenKit/Vendor/fmdb-fd95c38/FMDatabase.h @@ -26,7 +26,7 @@ #if TARGET_OS_IPHONE // Compiling for iOS - #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000 + #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000 || defined(ANDROID) // iOS 6.0 or later #define FMDBDispatchQueueRelease(__v) #else diff --git a/OpenKit/Vendor/fmdb-fd95c38/FMDatabaseAdditions.m b/OpenKit/Vendor/fmdb-fd95c38/FMDatabaseAdditions.m index aad558b..7c932fa 100644 --- a/OpenKit/Vendor/fmdb-fd95c38/FMDatabaseAdditions.m +++ b/OpenKit/Vendor/fmdb-fd95c38/FMDatabaseAdditions.m @@ -134,12 +134,15 @@ - (uint32_t)applicationID { } - (NSString*)applicationIDString { +#if defined(ANDROID) + id s = nil; +#else NSString *s = NSFileTypeForHFSTypeCode([self applicationID]); assert([s length] == 6); s = [s substringWithRange:NSMakeRange(1, 4)]; - +#endif return s; @@ -153,12 +156,13 @@ - (void)setApplicationID:(uint32_t)appID { } - (void)setApplicationIDString:(NSString*)s { - +#if !defined(ANDROID) if ([s length] != 4) { NSLog(@"setApplicationIDString: string passed is not exactly 4 chars long. (was %ld)", [s length]); } [self setApplicationID:NSHFSTypeCodeFromFileType([NSString stringWithFormat:@"'%@'", s])]; +#endif } #endif diff --git a/Vendor/AFNetworking/AFHTTPClient.m b/Vendor/AFNetworking/AFHTTPClient.m index 3fec759..5bb881a 100755 --- a/Vendor/AFNetworking/AFHTTPClient.m +++ b/Vendor/AFNetworking/AFHTTPClient.m @@ -205,6 +205,13 @@ @implementation AFHTTPClient @synthesize networkReachabilityStatusBlock = _networkReachabilityStatusBlock; #endif +#if defined(ANDROID) +-(void) setBaseURL:(NSURL *)baseURL +{ + _baseURL = baseURL; +} +#endif + + (instancetype)clientWithBaseURL:(NSURL *)url { return [[self alloc] initWithBaseURL:url]; } @@ -217,10 +224,18 @@ - (id)initWithBaseURL:(NSURL *)url { return nil; } +#if defined(ANDROID) + NSString *urlAbsoluteString = [url absoluteString]; + if (urlAbsoluteString.length && ![urlAbsoluteString hasSuffix:@"/"]) + { + url = [NSURL URLWithString:[NSString stringWithFormat:@"%@/", urlAbsoluteString]]; + } +#else // Ensure terminal slash for baseURL path, so that NSURL +URLWithString:relativeToURL: works as expected if ([[url path] length] > 0 && ![[url absoluteString] hasSuffix:@"/"]) { url = [url URLByAppendingPathComponent:@""]; } +#endif self.baseURL = url; @@ -237,7 +252,7 @@ - (id)initWithBaseURL:(NSURL *)url { #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) // User-Agent Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43 - [self setDefaultHeader:@"User-Agent" value:[NSString stringWithFormat:@"%@/%@ (%@; iOS %@; Scale/%0.2f)", [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleExecutableKey] ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleIdentifierKey], (__bridge id)CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), kCFBundleVersionKey) ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleVersionKey], [[UIDevice currentDevice] model], [[UIDevice currentDevice] systemVersion], ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] ? [[UIScreen mainScreen] scale] : 1.0f)]]; + [self setDefaultHeader:@"User-Agent" value:[NSString stringWithFormat:@"%@/%@ (%@; iOS %@; Scale/%0.2f)", [[[NSBundle mainBundle] infoDictionary] objectForKey:(__bridge NSString *)kCFBundleExecutableKey] ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(__bridge NSString *)kCFBundleIdentifierKey], (__bridge id)CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), kCFBundleVersionKey) ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(__bridge NSString *)kCFBundleVersionKey], [[UIDevice currentDevice] model], [[UIDevice currentDevice] systemVersion], ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] ? [[UIScreen mainScreen] scale] : 1.0f)]]; #elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) [self setDefaultHeader:@"User-Agent" value:[NSString stringWithFormat:@"%@/%@ (Mac OS X %@)", [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleExecutableKey] ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleIdentifierKey], [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"] ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleVersionKey], [[NSProcessInfo processInfo] operatingSystemVersionString]]]; #endif @@ -344,7 +359,7 @@ - (void)startMonitoringNetworkReachability { SCNetworkReachabilityContext context = {0, (__bridge void *)callback, AFNetworkReachabilityRetainCallback, AFNetworkReachabilityReleaseCallback, NULL}; SCNetworkReachabilitySetCallback(self.networkReachability, AFNetworkReachabilityCallback, &context); - SCNetworkReachabilityScheduleWithRunLoop(self.networkReachability, CFRunLoopGetMain(), (CFStringRef)NSRunLoopCommonModes); + SCNetworkReachabilityScheduleWithRunLoop(self.networkReachability, CFRunLoopGetMain(), (__bridge CFStringRef)NSRunLoopCommonModes); /* Network reachability monitoring does not establish a baseline for IP addresses as it does for hostnames, so if the base URL host is an IP address, the initial reachability callback is manually triggered. */ @@ -360,7 +375,7 @@ - (void)startMonitoringNetworkReachability { - (void)stopMonitoringNetworkReachability { if (_networkReachability) { - SCNetworkReachabilityUnscheduleFromRunLoop(_networkReachability, CFRunLoopGetMain(), (CFStringRef)NSRunLoopCommonModes); + SCNetworkReachabilityUnscheduleFromRunLoop(_networkReachability, CFRunLoopGetMain(), (__bridge CFStringRef)NSRunLoopCommonModes); CFRelease(_networkReachability); _networkReachability = NULL; } @@ -1127,6 +1142,8 @@ - (BOOL)hasBytesAvailable { case NSStreamStatusError: return NO; } + + return NO; } - (NSInteger)read:(uint8_t *)buffer maxLength:(NSUInteger)length { diff --git a/Vendor/AFNetworking/AFHTTPRequestOperation.m b/Vendor/AFNetworking/AFHTTPRequestOperation.m index 091f05b..d6afcdf 100755 --- a/Vendor/AFNetworking/AFHTTPRequestOperation.m +++ b/Vendor/AFNetworking/AFHTTPRequestOperation.m @@ -120,8 +120,23 @@ @implementation AFHTTPRequestOperation @synthesize failureCallbackQueue = _failureCallbackQueue; @synthesize totalContentLength = _totalContentLength; @synthesize offsetContentLength = _offsetContentLength; -@dynamic request; + +#if defined(ANDROID) +@synthesize response = _response; +-(void) setResponse:(NSHTTPURLResponse *)response +{ + _response = response; +} + +@synthesize request = _request; +-(void) setRequest:(NSURLRequest *)request +{ + _request = request; +} +#else @dynamic response; +@dynamic request; +#endif - (void)dealloc { if (_successCallbackQueue) {