ios利用單例實現(xiàn)不同界面間的數(shù)據(jù)傳輸
來源:易賢網(wǎng) 閱讀:1210 次 日期:2014-12-08 11:21:49
溫馨提示:易賢網(wǎng)小編為您整理了“ios利用單例實現(xiàn)不同界面間的數(shù)據(jù)傳輸”,方便廣大網(wǎng)友查閱!

首先寫一個單例類,繼承nsobject

check.h文件中

@property(strong ,nonatomic) uitable * table;

@property(strong ,nonitomic) uitextfiled * text;

+(check*)sharedatamodle;

check.m中

//定義一個靜態(tài)的checke類的對象,并賦給一個空值

static check * datamodle = nil;

+(check*)sharedatamodle

{

if (datamodle == nil)

{

datamodle = [[check alloc]init];

}

}

//在數(shù)據(jù)源將數(shù)據(jù)賦值給單例的對象

-(void)checkdatasource

{

[check sharedatamodle].lable = @15;

[check sharedatamodle].text = @22;

}

//引入單例的頭文件 ,在對應(yīng)定的方法中給對應(yīng)的對象賦值

//將單例中的屬性值傳給當前界面中的接收對象,到此就完成了數(shù)據(jù)的傳送和接收

-(void)viewwillappear:(bool)animated

{

[super viewwillappear:animated];

self.numberlable.text=[check sharedatamodle].lable;

self.danhao.text = [check sharedatamodle].text;

更多信息請查看IT技術(shù)專欄

更多信息請查看技術(shù)文章
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點

版權(quán)所有:易賢網(wǎng)