object reference is same in function calling

后端 未结 3 1542
独厮守ぢ
独厮守ぢ 2021-01-26 01:06
 -(UserDetail *)functionCheck :(NSString *)str
 {
    UserDetail *d2=[[UserDetail alloc] init];
    NSLog(@\"check address::::::> %p\",&d2);
    d2.auth_token=str         


        
3条回答
  •  北海茫月
    2021-01-26 02:06

    d2 is a pointer to the allocated object, so what you want is to log the value of d2, not its address &d2:

    NSLog(@"check address::::::> %p", d2); // remove the & !
    

    (&d2 is the address of the local stack variable, and that may be the same for each call.)

提交回复
热议问题