From 06c96cbb6e8df4d19a7f76dec23d3876e305da02 Mon Sep 17 00:00:00 2001 From: Fernando N Sousa Date: Mon, 6 Jun 2016 12:52:32 -0300 Subject: [PATCH] prevent nil exception if no data received --- TMLog/TMLog.m | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/TMLog/TMLog.m b/TMLog/TMLog.m index a0917b1..a41cb89 100644 --- a/TMLog/TMLog.m +++ b/TMLog/TMLog.m @@ -52,7 +52,13 @@ - (BOOL) canSendLogs { } - (NSString *) getLogMessage:(NSNotification *)notification { - return [[NSString alloc] initWithData: [[notification userInfo] objectForKey: NSFileHandleNotificationDataItem] encoding: NSUTF8StringEncoding]; + NSData *dataReceived = [[notification userInfo] objectForKey: NSFileHandleNotificationDataItem]; + + if (dataReceived != nil) { + return [[NSString alloc] initWithData: dataReceived encoding: NSUTF8StringEncoding]; + } + + return @""; } - (void) sendLog:(NSString *)logMessage {