Last active
December 10, 2015 10:38
-
-
Save joekr/4422453 to your computer and use it in GitHub Desktop.
Subscription With Block
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface DataController : NSObject | |
- (void) getSubscriptionFromServer onComplete:(void (^)(void)) completionBlock | |
onCancelled:(void (^)(void)) cancelBlock; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface DataController() | |
@property (nonatomic, copy) void (^onTransactionCancelled)(); | |
@property (nonatomic, copy) void (^onTransactionCompleted)(SKPaymentTransaction *transaction); | |
@end | |
@implementation DataController | |
@synthesize onTransactionCancelled; | |
@synthesize onTransactionCompleted; | |
- (void) getSubscriptionFromServer onComplete:(void (^)(void)) completionBlock | |
onCancelled:(void (^)(void)) cancelBlock{ | |
self.onTransactionCompleted = completionBlock; | |
self.onTransactionCancelled = cancelBlock; | |
[self getSubscription]; | |
} | |
- (void) getSubscriptionFromServer { | |
// do some stuff if(success == ture){ | |
if(success == true){ | |
if(self.onTransactionCompleted){ | |
self.onTransactionCompleted(); | |
} | |
}else{ | |
if(self.onTransactionCancelled){ | |
self.onTransactionCancelled(); | |
} | |
} | |
} | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void) findSubscription{ | |
[myObject getSubscriptionFromServer onComplete:^ { | |
//Handle subscription call passed | |
} | |
onCancelled:^{ | |
//Handle subscription call failed | |
}]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment