Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


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,842 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!