objective c - Sharing Property information between classes in Obj C -
i've been trying share information 1 of classes 1 (trying out spritebuilder) , it's just. not. working.
i want change text of label in second class string define in first. here code.
mainscene.h
@interface mainscene : ccnode @property cclabelttf *lblchange; -(void) _button; @end
mainscene.m
#import "mainscene.h" #import "storyscene.h" @implementation mainscene -(void)_button { startscene *starthold = [[startscene alloc] init]; [starthold.lbltwo setstring:@"hello world!"]; nslog(@"%@, storyscene", starthold); nslog(@"%@, main scene", @"yessss"); nsstring *filler = [starthold.lbltwo string]; nslog(@"%@",filler); ccscene *storyscene = [ccbreader loadasscene:(@"startscene")]; [[ccdirector shareddirector] replacescene: storyscene]; } @end
storyscene.h
#import "ccnode.h" @interface startscene : ccnode @property cclabelttf *lbltwo; @end
storyscene.m
#import "storyscene.h" @implementation storyscene @end
i've tried making storyscene property in mainscene class, synthesizing pretty everything, moving things around - cannot dogging lbltwo
log anything, prevents label text changing (i think). here relevant output in log.
thecaveofman[58721:1593076] <startscene = 0x7fc2cfb31e40 | name = (null)>, storyscene 2015-06-18 15:52:04.712 thecaveofman[58721:1593076] yessss, main scene 2015-06-18 15:52:04.712 thecaveofman[58721:1593076] <startscene = 0x7fc2cfb31e40 | name = (null)>, label 2015-06-18 15:52:04.713 thecaveofman[58721:1593076] (null) 2015-06-18 15:52:04.714 thecaveofman[58721:1593076] ccbreader: couldn't find member variable: lbltwo 2015-06-18 15:52:04.725 thecaveofman[58721:1593076] cocos2d: surface size: 640x1136
i don't know why can't find lbltwo variable, , don't know how change storyscene's logging name isn't (null)
, or how give lbltwo string
hold. help?
at second line, try assign "hello world", think lbltwo property might uninitialised (so nil). need alloc , init property before calling setstring on it.
Comments
Post a Comment