diff --git a/ChimpKit3/ChimpKit.m b/ChimpKit3/ChimpKit.m index c249120..70b98da 100644 --- a/ChimpKit3/ChimpKit.m +++ b/ChimpKit3/ChimpKit.m @@ -43,6 +43,7 @@ + (ChimpKit *)sharedKit { dispatch_once(&pred, ^{ _sharedKit = [[self alloc] init]; _sharedKit.timeoutInterval = kDefaultTimeoutInterval; + _sharedKit.requests = [[NSMutableDictionary alloc] init]; }); return _sharedKit; @@ -164,10 +165,10 @@ - (NSUInteger)callApiMethod:(NSString *)aMethod withApiKey:(NSString *)anApiKey requestWrapper.delegate = aDelegate; requestWrapper.completionHandler = aHandler; - [self.requests setObject:requestWrapper forKey:[NSNumber numberWithUnsignedInteger:[dataTask taskIdentifier]]]; - [dataTask resume]; + [self.requests setObject:requestWrapper forKey:[NSNumber numberWithUnsignedInteger:[dataTask taskIdentifier]]]; + return [dataTask taskIdentifier]; } @@ -217,7 +218,7 @@ - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didComp } } - [self.requests removeObjectForKey:[NSNumber numberWithUnsignedInteger:[requestWrapper.dataTask taskIdentifier]]]; + [self.requests removeObjectForKey:[NSNumber numberWithUnsignedInteger:[task taskIdentifier]]]; }