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

Ali Zaheer
Ali Zaheer
919 Points

I need help, someone explain this to me.

What does this mean in Objective-C?

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) 

If I remove the (int main....) some things don't work for example like the loop for doesn't show up as a suggested. Can someone give me I detailed explanation on what this does and is there a video on tree house that goes over this, this is one of the main reasons I left lynda.com and went here because they did not explain this (Unless I'm blind I couldn't find it.) Thanks!

1 Answer

Michael Hulet
Michael Hulet
47,913 Points

This is a C thing, and very few beginner guides cover it (I don't think Treehouse does) because of its relative obscurity. Ultimately, there are very few reasons that you should modify this file. It's far preferable to perform whatever instantiation work in Objective-C or Swift in your app delegate instead. That being said, this is your app's entry point. When a user launches your app, this is the function that iOS calls to tell your app to run. This function should generally only include a single call to UIApplicationMain (the function that actually starts and runs your app) and nothing else. In Swift, this was shortened to a single directive (@UIApplicationMain) that you put at the top of your app delegate, so it's impossible to modify this function at all, as it's just a compiler directive and not a function. However, props to you for experimenting!