From 5b47ac5e42104089db078eb39a41a6f2b5672858 Mon Sep 17 00:00:00 2001 From: Andrew Bruce Date: Thu, 7 Apr 2016 21:17:24 +0100 Subject: [PATCH] Update objc tutorial1 for subscription errors Also, log before connecting for receive. [#116521563] --- objective-c/tutorial1/Cartfile.resolved | 2 +- objective-c/tutorial1/tutorial1/ViewController.m | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/objective-c/tutorial1/Cartfile.resolved b/objective-c/tutorial1/Cartfile.resolved index 5c0c9dc..324af5c 100644 --- a/objective-c/tutorial1/Cartfile.resolved +++ b/objective-c/tutorial1/Cartfile.resolved @@ -1,3 +1,3 @@ github "robbiehanson/CocoaAsyncSocket" "562bae6af6dbd7e1891293dae20b9f79a2fd7228" github "Mantle/Mantle" "cdb82df5dd3a7e4cfab6dfbc48df20dcc80b4e13" -github "rabbitmq/rabbitmq-objc-client" "7871c3ab0e731b6cc8b9bb1ac0ef5a410bc035ce" +github "rabbitmq/rabbitmq-objc-client" "3e36e6db95769016ea38765ff6255e932867c89d" diff --git a/objective-c/tutorial1/tutorial1/ViewController.m b/objective-c/tutorial1/tutorial1/ViewController.m index 4ed3ced..9da0ae4 100644 --- a/objective-c/tutorial1/tutorial1/ViewController.m +++ b/objective-c/tutorial1/tutorial1/ViewController.m @@ -13,10 +13,8 @@ } - (void)send { - RMQConnection *conn = [RMQConnection new]; - NSLog(@"Attempting to connect to local RabbitMQ broker"); - + RMQConnection *conn = [RMQConnection new]; NSError *error = NULL; [conn startWithError:&error]; if (error) { @@ -38,6 +36,7 @@ } - (void)receive { + NSLog(@"Attempting to connect to local RabbitMQ broker"); RMQConnection *conn = [RMQConnection new]; NSError *error = NULL; [conn startWithError:&error]; @@ -55,11 +54,14 @@ RMQQueue *q = [ch queue:@"hello"]; NSLog(@"Waiting for messages."); - [q subscribe:^(id _Nonnull m) { - NSLog(@"Received %@", m.content); - [conn close]; - exit(0); + [q subscribeWithError:&error handler:^(id _Nonnull message) { + NSLog(@"Received %@", message.content); }]; + if (error) { + NSLog(@"Error subscribing: %@", error); + [conn close]; + exit(1); + } } @end