been having a little confusion about the retainCount of NSURLConnection

前端 未结 2 568
星月不相逢
星月不相逢 2020-12-11 11:51

first look at these code:

NSURL *url = [[NSURL alloc] initWithString:@\"lasdhfkjasf\"];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
NSURL         


        
2条回答
  •  庸人自扰
    2020-12-11 12:41

    Whilst not technically a duplicate of the question Nikolai linked to, the same thing applies:

    Don't use the retainCount property

    It's possibly the worst thing Apple ever put into NSObject, because it's so nicely named it tricks you into thinking it's actually useful.

    See the question you were previously linked to - Objective C NSString* property retain count oddity - but look for the second answer, the highest rated one.

提交回复
热议问题