Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Why is NSLog called like a C method rather than an Obj-C method?

So NSLog is a method that writes to the console. But when we call it, we say

NSLog(@"Blah Blah Blah");

rather than

[NSLog @"Blah Blah Blah"];

Any reason behind this? Or is the second way possible to do? The question is kinda stupid, but it's really bugging me as to why we do it this way...

1 Answer

Michael Hulet
Michael Hulet
47,912 Points

We call it like a C function because it is a C function, not a method. A method is tied to a specific class, where NSLog is not

Oh okay... So not part of any Object means call it like a function. Got it!