ios - how to pass the pointer in objective c? -
i'm developing mini quiz game. in opening xib, preferred username using methods below , pass model(modelunit):
//intro.h @interface introviewcontroller : uiviewcontroller{ modelunit * modl; } //intro.m -(modelunit *) modl{ if(!modl){ modl = [[modelunit alloc] init]; } return modl; } - (ibaction)nickentered:(uitextfield *)sender{ [[self modl] setname:[sender text]]; ..... }
however, when try create pointer points modelunit in sequentially last xib, returns username null. assume has same pointer reach same location. how can go it? help.
you not setting right. how refer 'modl' in 2 different ways in intro.m file
[self modl] refers property called 'modl' normal use of 'modl' refers variable declared in interface.
this suggests not storing username in 'modl' object created. or have 2 'modl' objects. (would have see complete code know sure)
to able access 'modl' outside view/class have create getter returns 'modl'. hand or declare property use instead of variable (@property) automatically comes getter , setter. still requires have reference intro object. if not have store somewhere else, or pass along hot licks suggested.
Comments
Post a Comment