You have simple one-time tasks that require a progress bar. OpenSSL has a useful callback that you can use to do this:
rsa=RSA_generate_key(bits,RSA_F4,progressCallback,NULL);
from
static void callback(int p, int n, void *arg) { .. stuff
However, I want to call it from ObjectiveC without much ado:
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; hud.mode = MBProgressHUDModeAnnularDeterminate; hud.labelText = @"Generating CSR"; [self genReq:^(int p,int n,void *arg) { hud.progress = --heuristic to guess where we are -- } completionCallback:^{ [MBProgressHUD hideHUDForView:self.view animated:YES]; }];
With Genrec: as an objC method:
-(void)genReq:(void (^)(int,int,void *arg))progressCallback completionCallback:(void (^)())completionCallback { ..... rsa=RSA_generate_key(bits,RSA_F4,progressCallback,NULL); assert(EVP_PKEY_assign_RSA(pkey,rsa)); rsa=NULL; .... completionCallback(); }
Now completeCallback (); Works great and as expected. But I get a compiler warning / error that I cannot suppress for the progress callback:
Passing 'void (^__strong)(int, int, void *)' to parameter of incompatible type 'void (*)(int, int, void *)'
So curious - which way to do it?
Thanks,
Dw.