objective c - Default Cocoa Application ViewController.m issue? -
newbie question follows...
i learning objective c based os x cocoa app development. of books , videos have ios, converting simple ios code examples os x.
when create new os x "cocoa application" project, "use storyboards" box checked, default viewcontroller.m in newly created project not have @interface section. expected?
a reply recent question cocoa viewcontroller.m vs. cocoa touch viewcontroller.m indicates user's default viewcontroller.m have @interface section.
currently, manually typing @interface section iboutlets. others doing? or have configuration issue?
i using xcode 6.3.2 on yosemite.
here default viewcontroller.m
// // viewcontroller.m // testme // // created me on 6/19/15. // copyright (c) 2015 me. rights reserved. // #import "viewcontroller.h" @implementation viewcontroller - (void)viewdidload { [super viewdidload]; // additional setup after loading view. } - (void)setrepresentedobject:(id)representedobject { [super setrepresentedobject:representedobject]; // update view, if loaded. } @end
typically interface class (viewcontroller in case) in header file (.h).
however developers use convention of putting class extension @ top of implementation files way of "faking" private methods (which objective c doesn't have.)
so see in .m file:
//the parenthesis here indicate class extension. @interface viewcontroller () //only viewcontroller class sees method. -(void) method; @end @implementation viewcontroller -(void) method{ //do stuff here } @end
this not specific ios or macos rather objective c. can see more objective c class extensions here.
the default xcode project not add class extension created viewcontroller class. if create new nsviewcontroller subclass (by going file->new->file->cocoa class, create class subclass of nsviewcontroller, notice new nsviewcontroller subclass have class extension generated @ top of implementation file. not required or necessary, used way of defining closest thing objective c allows private interface.
you can check out this answer more details implementing psuedo-private methods.
Comments
Post a Comment