Thanks @Paulw11, now I understand. Execution just continues after the call to the Swift code, you need to just let the completion block do it's thing, and handle things from there.
The Objective-C code now is:
- (void) ReceiptValidatedWith:(int)validation_code
{
if (validation_code != 1) {
ALog(@"AppStore receipt invalid, exiting.");
[NSApp terminate:self];
}
else {
ALog(@"AppStore receipt VALID, continuing.");
}
}
- (void) validateReceipt
// Validating receipt now only possible via Swift, call method AppTransaction.shared in swift module.
// As that all is async code we need to jump through some hoops to get at the value of the validity code.
{
ALog(@"validating receipt...");
[self.receiptValidation getValidityOfAppStoreReceiptWithCompletionHandler:^(NSInteger validation_code, NSError *error) {
[self ReceiptValidatedWith:validation_code]; // called on completion of the Swift code
}];
}
Just for the heck of it the code to interface to Swift:
.h
// AppStore receipt validation module (Swift)
@property (nonatomic,strong) ReceiptValidation *receiptValidation; // swift
.m
@synthesize receiptValidation; // swift module
// AppStore receipt validation with swift module
self.receiptValidation = [[ReceiptValidation alloc] init];