Steve Brown
Steve Brown

Reputation: 1416

How can I log the current line via NSLog in Cocoa / Objective C?

Is it possible to log the current line number using NSLog in Cocoa / Objective C?

This is what I thought I should do:

NSLog(@"current line: %@ and value: %@",__LINE__,abc);

And I'm getting Thread 1: Program Received Signal: "EXC_BAD_ACCESS"

Upvotes: 1

Views: 748

Answers (1)

David V
David V

Reputation: 11699

The __LINE__ macro provides an integer so you need to change your format string. Instead of %@ you need a %d.

NSLog(@"current line: %d",__LINE__);

Upvotes: 6

Related Questions