Как я могу распечатать Адрес памяти переменной?

Я сделал это, определив FormControl для FormGroup следующим образом:

{
  controlName: new FormControl({
    validators: [ Validators.required, etc ]
    asyncValidators: yourValidatorFunction(),
    updateOn: 'blur',
  }),
}
14
задан Cœur 16 April 2017 в 07:05
поделиться

2 ответа

The argument to NSLog needs to be an NSString, so you want

NSLog(@"%p", &myIntVar);
37
ответ дан 1 December 2019 в 06:48
поделиться

Try:

NSLog(@"%p", &myIntVar);

or

NSLog(@"%lx", (long)&myIntVar);

The first version uses the pointer-specific print format, which assumes that the passed parameter is a pointer, but internally treats it as a long.

The second version takes the address, then casts it to a long integer. This is necessary for portability on 64-bit platforms, because without the "l" format qualifier it would assume that the supplied value is an integer, typically only 32-bits long.

5
ответ дан 1 December 2019 в 06:48
поделиться
Другие вопросы по тегам:

Похожие вопросы: