objective c - Either AppDelgate is called or ViewController is -
i wanting both appdelegate , viewcontroller called on startup (as expected).
when viewcontroller called:
main.c
int main(int argc, const char * argv[]) { return nsapplicationmain(argc, argv); }
when appdelegate called , view controller not.
main.c
#import "appdelegate.h" int main(int argc, const char *argv[]) { nsarray *tl; nsapplication *application = [nsapplication sharedapplication]; [[nsbundle mainbundle] loadnibnamed:@"viewcontroller" owner:application toplevelobjects:&tl]; appdelegate *applicationdelegate = [[appdelegate alloc] init]; // instantiate app delegate [application setdelegate:applicationdelegate]; // assign delegate nsapplication [application run]; // call apps run method return 0; // app never gets here. }
i think problem second attempt of main.c that...
nsapplication *application = [nsapplication sharedapplication]; [[nsbundle mainbundle] loadnibnamed:@"viewcontroller" owner:application toplevelobjects:&tl];
is not working expected. set 'nib' in ib?
what wrong?
you've got kind of confused.... should more closely @ other answer on here: other answer
your first main.c example wrong. second main.c, closer example gave better, you're calling viewcontroller should referencing mainmenu nib, in example.
this line wrong:
[[nsbundle mainbundle] loadnibnamed:@"viewcontroller" owner:application toplevelobjects:&tl];
put nib name there... that's why method argument called "loadnibnamed" :)- , rid of @"viewcontroller".
now if trying call full blown nib, don't need example. designed people trying programmatic.
Comments
Post a Comment