Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated canceling operations. #6

Merged
merged 1 commit into from
Sep 2, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions JBMessage.podspec
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
Pod::Spec.new do |s|
s.name = "JBMessage"
s.version = "1.0.12"
s.version = "1.0.13"
s.summary = "JBMessage is simple iOS networking wrapper based on AFNetworking"
s.homepage = "https://github.com/josipbernat/JBMessage"
s.license = { :type => "MIT", :file => "LICENSE" }
s.author = { "Josip Bernat" => "[email protected]" }
s.social_media_url = "http://twitter.com/josipbernat"
s.platform = :ios, "6.0"
s.source = { :git => "https://github.com/josipbernat/JBMessage.git", :tag => "v1.0.12" }
s.source = { :git => "https://github.com/josipbernat/JBMessage.git", :tag => "v1.0.13" }
s.source_files = 'JBMessage/JBMessage/**/*.{h,m}'
s.requires_arc = true
s.dependency "AFNetworking", "~> 2.3.1"
s.dependency "AFNetworking", "~> 2.3"
end

8 changes: 8 additions & 0 deletions JBMessage/JBMessage/JBMessage.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ @interface JBMessage () {
BOOL _isExecuting;
}

@property (nonatomic, strong) AFHTTPRequestOperation *operation;

#pragma mark - Shared Queue
+ (NSOperationQueue *)sharedQueue;

Expand Down Expand Up @@ -224,7 +226,10 @@ - (void) finish {
}

- (void) cancel {

_isCancelled = YES;
[self.operation cancel];
self.operation = nil;
}

- (BOOL) isConcurrent {
Expand Down Expand Up @@ -270,13 +275,16 @@ - (void)executeRequest {

__strong JBMessage *strongThis = this;
[strongThis receivedResponse:responseObject error:nil];
strongThis.operation = nil;

} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
#ifdef DEBUG
NSString *response = [[NSString alloc] initWithData:operation.responseData encoding:NSUTF8StringEncoding];
if (response && response.length) { NSLog(@"Response error: %@", response); }
#endif
__strong JBMessage *strongThis = this;
[strongThis receivedResponse:operation.responseData error:error];
strongThis.operation = nil;
}];

[operation setUploadProgressBlock:self.uploadBlock];
Expand Down
2 changes: 1 addition & 1 deletion Podfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
platform :ios, '6.0'
pod 'AFNetworking', '~> 2.3.1'
pod 'AFNetworking', '~> 2.3'
2 changes: 1 addition & 1 deletion Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ PODS:
- AFNetworking/NSURLSession

DEPENDENCIES:
- AFNetworking (~> 2.3.1)
- AFNetworking (~> 2.3)

SPEC CHECKSUMS:
AFNetworking: 6d7b76aa5d04c8c37daad3eef4b7e3f2a7620da3
Expand Down