在A类我有:
classB *classBI=[[classB alloc]init];
bits=[classBI data]; //bits has a property here in classA,it gets data from B/
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(38.f, 20.f, 244.f, 43.f)];
label.text = bits;
在B类我有:
@property (nonatomic,retain) NSString *data; //in .h file
data=@"no data"; //at the init method of classB .
//then after a while when something is happen in classB , data is changed to :
data=[NSString stringWithFormat:@"data:%f,%f,%f,%f,%f,%f",
dataBits[0],dataBits[1],dataBits[2],dataBits[3],dataBits[4],dataBits[5] ];
classA 是主场景(cocos2d 不过没关系)。一开始我真的可以在标签中看到classA中的“无数据”一词,但是当classB中的数据发生变化时,我看不到屏幕上标签的变化。它坚持这个词:“没有数据”为什么会这样?为什么我丢失了数据?如果我在 classB 中的 NSLOG 数据,就在它在那里改变之后,我可以看到它不为空,并且它具有新值。获取此字符串的 A 中 B 的实例有问题。