首先寫一個單例類,繼承NSObject
check.h文件中
@property(strong ,nonatomic) UITable * Table;
@property(strong ,nonitomic) UITextFiled * Text;
+(check*)shareDataModle;
check.m中
//定義一個靜態的checke類的對象,並賦給一個空值
static check * dataModle = nil;
+(check*)shareDataModle
{
if (dataModle == nil)
{
dataModle = [[check alloc]init];
}
}
//在數據源將數據賦值給單例的對象
-(void)checkDataSource
{
[check shareDatamodle].Lable = @"15";
[check shareDatamodle].Text = @"22";
}
//引入單例的頭文件 ,在對應定的方法中給對應的對象賦值
//將單例中的屬性值傳給當前界面中的接收對象,到此就完成了數據的傳送和接收
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.numberLable.text=[check shareDataModle].Lable;
self.danHao.text = [check shareDataModle].Text;
}