首先寫(xiě)一個(gè)單例類(lèi),繼承nsobject
check.h文件中
@property(strong ,nonatomic) uitable * table;
@property(strong ,nonitomic) uitextfiled * text;
+(check*)sharedatamodle;
check.m中
//定義一個(gè)靜態(tài)的checke類(lèi)的對(duì)象,并賦給一個(gè)空值
static check * datamodle = nil;
+(check*)sharedatamodle
{
if (datamodle == nil)
{
datamodle = [[check alloc]init];
}
}
//在數(shù)據(jù)源將數(shù)據(jù)賦值給單例的對(duì)象
-(void)checkdatasource
{
[check sharedatamodle].lable = @15;
[check sharedatamodle].text = @22;
}
//引入單例的頭文件 ,在對(duì)應(yīng)定的方法中給對(duì)應(yīng)的對(duì)象賦值
//將單例中的屬性值傳給當(dāng)前界面中的接收對(duì)象,到此就完成了數(shù)據(jù)的傳送和接收
-(void)viewwillappear:(bool)animated
{
[super viewwillappear:animated];
self.numberlable.text=[check sharedatamodle].lable;
self.danhao.text = [check sharedatamodle].text;
}
更多信息請(qǐng)查看IT技術(shù)專(zhuān)欄