NSTimer 前進的火車 新浪部落格

2021-10-10 12:04:18 字數 839 閱讀 7565

//             第1種方式

//            此種方式建立的timer已經新增至runloop中 [

nstimer

scheduledtimerwithtimeinterval:

1.0f

target:

selfselector:

@selector

(settimer) userinfo:

nilrepeats:

yes];

//  保持執行緒為活動狀態,才能保證定時器執行

[[nsrunloop

currentrunloop

] run

];//已經將nstimer新增到nsrunloop中了

//            //第2種方式

//            //此種方式建立的timer沒有新增至runloop中

nstimer *timer = [nstimer

timerwithtimeinterval:1.0f

target:self

selector:@selector(settimer) userinfo:nil

repeats:yes];

//將定時器新增到

runloop中

[[nsrunloop

currentrunloop] addtimer:timer formode:nsdefaultrunloopmode];

[[nsrunloop

currentrunloop] run];

nslog(@"

多執行緒結束

");

udp 前進的火車 新浪部落格

udp通訊協議的特點 1.將資料極封裝為資料報,面向無連線。2.每個資料報大小限制在64k中 3.因為無連線,所以不可靠 4.因為不需要建立連線,所以速度快 5.udp 通訊是不分服務端與客戶端的,只分傳送端與接收端。比如 物管的對講機,遊戲.udp協議下的socket datagramsocket...

List Set 前進的火車 新浪部落格

collection 單列集合的根介面 list 如果實現了list介面的集合類,具備的特點 有序,可重複。arraylist arraylist 底層是維護了乙個object陣列實現 的,特點 查詢速度快,增刪慢。linkedlist linkedlist底層是使用了鍊錶資料結構實現的,特點 查詢...

Label Button 前進的火車 新浪部落格

1.label uilabel label uilabel alloc init 建立 self label label 關聯到當前屬性 label.text 顯示的內容 顯示的內容 cgfloat width self view.bounds.size.width 獲取螢幕的寬度 label.fr...