Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Will0827

macrumors regular
Original poster
Aug 11, 2008
155
17
Im going over the source code for something i want to implement into my project and noticed some lines in the .m files of the source code and there are some methods that look like this

- (BOOL)isToday { return [self isEqual:today]; }
- (unsigned int)day { return a.day; }

in the h files these methods don't have any arguments but in the .m files they have these curly brace arguments. Im not sure as what there use is. Any one care to help, thanks.
 
The curly braces indicate the start and end of the method. Generally they'd be on seperate lines, but neither C nor Obj-C actually care about line breaks. Line breaks are mostly just used to make code easier to read.
 
Darn now I feel kinda stupid. I guess because I'm so used to seeing the opening curly brace be placed on the following line after the method name I found it weird at first. Thanks for the reply.
 
Every developer has their own ideas about where the braces go. Some are downright odd. These methods are obviously meant to take up as little space as possible. It's also reminiscent of the way some people write inline methods in the headers of C++ classes.
 
Im going over the source code for something i want to implement into my project and noticed some lines in the .m files of the source code and there are some methods that look like this

- (BOOL)isToday { return [self isEqual:today]; }
- (unsigned int)day { return a.day; }

in the h files these methods don't have any arguments but in the .m files they have these curly brace arguments. Im not sure as what there use is. Any one care to help, thanks.

I wouldn't be alive to post this if my school computer teacher ever found me doing this :D
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.