Skip to content
This repository has been archived by the owner on Jun 23, 2021. It is now read-only.

Commit

Permalink
Merge branch 'master' of https://github.com/mattt/CargoBay
Browse files Browse the repository at this point in the history
  • Loading branch information
mattt committed May 2, 2013
2 parents b66009c + a48d241 commit 9b6153e
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions CargoBay/CargoBay.m
Original file line number Diff line number Diff line change
Expand Up @@ -1078,24 +1078,26 @@ - (id)initWithSuccess:(void (^)(NSArray *, NSArray *))success

#if __has_feature(objc_arc_weak)
__weak __typeof(&*self)weakSelf = self;
#else
__unsafe_unretained __typeof(&*self)weakSelf = self;
#endif

_success = [^(NSArray *products, NSArray *invalidIdentifiers) {
if (success) {
success(products, invalidIdentifiers);
}

#if __has_feature(objc_arc_weak)
[[weakSelf class] unregisterDelegate:weakSelf];
#endif
} copy];

_failure = [^(NSError *error) {
if (failure) {
failure(error);
}

#if __has_feature(objc_arc_weak)
[[weakSelf class] unregisterDelegate:weakSelf];
#endif
} copy];


Expand All @@ -1107,11 +1109,21 @@ - (id)initWithSuccess:(void (^)(NSArray *, NSArray *))success
- (void)request:(SKRequest *)request
didFailWithError:(NSError *)error
{
#if !__has_feature(objc_arc_weak)
[[self class] unregisterDelegate:self];
#endif
if (_failure) {
_failure(error);
}
}

- (void)requestDidFinish:(SKRequest *)request
{
#if !__has_feature(objc_arc_weak)
[[self class] unregisterDelegate:self];
#endif
}

#pragma mark - SKProductsRequestDelegate

- (void)productsRequest:(SKProductsRequest *)request
Expand Down

0 comments on commit 9b6153e

Please sign in to comment.