国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

objective-c - ios開發(fā)中self和下劃線的區(qū)分
黃舟
黃舟 2017-04-27 09:02:53
0
3
969

今天碰到一個問題,就是用到懶加載的時候,我用了self,結(jié)果報錯直接蹦了,

我們老師說這是self遞歸引用了,可我還是不明白它們之間的區(qū)別

黃舟
黃舟

人生最曼妙的風(fēng)景,竟是內(nèi)心的淡定與從容!

reply all(3)
洪濤

Self. _x is the automatically created instance variable.
For example, you define the following attribute:

@property(nonation, strong) NSString *x;

There is a bunch of hidden (simplified) code as follows:

NSString *_x;

-(NSString *)x {
    return _x;
}

-(void)setX:(NSString *)x {
    _x = x;
}

I guess your lazy loading code overloads the get method of the attribute. Self.x actually calls the [self x] method. If you use self.x in the get method, then self.x calls it again. , [self x] method, this is infinite recursion.

黃舟

If it is referenced, there will be no difference. It is the same pointer. If it is assigned, there is a difference. self.xx=oo First, xxretaincount -1 and then retain oo _XX is copied to point directly to oo. There is no retain step. Nor

曾經(jīng)蠟筆沒有小新

I just guessed that you might be:

self.some = [self some];
-(type)some{
    self.some = [...];
}

Then when you call self.some, it is equivalent to using [self some], and self.some in some calls [self some] again. . . A loop is formed. . .

Underscore means direct access, bypassing set and get. .

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