亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

objective-c - 在oc里面點(diǎn)號和中括號發(fā)送消息的區(qū)別
PHP中文網(wǎng)
PHP中文網(wǎng) 2017-04-21 10:57:14
0
3
723

本來我以為在oc里面發(fā)送一個(gè)消息只能用中括號的

后來一個(gè)typo讓我發(fā)現(xiàn)其實(shí)直接像c++那樣用點(diǎn)號也是可以發(fā)送消息,只不過會多一個(gè)警告,內(nèi)容看不太明白

很奇怪他說得并不是deprecated什么的,而是說這么用有副作用,不只看有誰能幫我解析一下這里說的副作用是什么意思

相關(guān)代碼

// 申明
@property (weak, nonatomic) IBOutlet UITextField *textfield; 

// 運(yùn)行代碼
self.textfield.resignFirstResponder; //寫成這樣會出警告,但是能運(yùn)行

[self.textfield resignFirstResponder]; // 按這樣的標(biāo)準(zhǔn)寫法就沒事
PHP中文網(wǎng)
PHP中文網(wǎng)

認(rèn)證0級講師

reply all(3)
小葫蘆

This line of warning is like this. It does not mean that there are any side effects if you do this, but it means that the getter is used to obtain the value, and sending resignFirstResponder is a side effect. It is not recommended to use the getter.
The .number is equal to the getter and setter methods on the properties of @synthesize

阿神

The literal translation is: the return value of the attribute is not used.
In other words: should
a =b.c;
It is not recommended to use it directly
b.c;
Unlike class methods, you can use methods like this:
o.method();

黃舟

I learned that the resignFirstResponder method is generally used to send messages.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template