Skip to content

Commit

Permalink
prevent nil exception if no data received
Browse files Browse the repository at this point in the history
  • Loading branch information
fnazarios committed Jun 6, 2016
1 parent 134555c commit 06c96cb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion TMLog/TMLog.m
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 06c96cb

Please sign in to comment.