From 73f06b39bcb093712bbce1ef84ef32916528dedc Mon Sep 17 00:00:00 2001 From: "Justin R. Miller" Date: Wed, 19 Feb 2014 12:41:15 -0800 Subject: [PATCH] fixes #72: clean up & make callbacks clearer --- ios/MBXViewController.mm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ios/MBXViewController.mm b/ios/MBXViewController.mm index c5d6effa1..28bee82ce 100644 --- a/ios/MBXViewController.mm +++ b/ios/MBXViewController.mm @@ -385,7 +385,7 @@ namespace llmr { } - void request_http(std::string url, std::function func, std::function cb) + void request_http(std::string url, std::function background_function, std::function foreground_callback) { [[NSNotificationCenter defaultCenter] postNotificationName:MBXUpdateActivityNotification object:nil userInfo:[NSDictionary dictionaryWithObject:@1 forKey:@"count"]]; @@ -407,10 +407,11 @@ namespace llmr res.body = { (const char *)[data bytes], [data length] }; } - func(res); + background_function(res); - dispatch_async(dispatch_get_main_queue(), ^(void) { - cb(); + dispatch_async(dispatch_get_main_queue(), ^(void) + { + foreground_callback(); }); [[NSNotificationCenter defaultCenter] postNotificationName:MBXUpdateActivityNotification object:nil userInfo:[NSDictionary dictionaryWithObject:@(-1) forKey:@"count"]];