ios 打印对象指针地址和内存地址

2019-12-20  本文已影响0人  liang1030

OC:

NSString *str = @"lu";
NSLog(@"%p - %p",str, &str);

Swift:

var str = "lu"

内存地址:
print(String(format: "%p", str))

指针地址:
let pointer = withUnsafePointer(to: &str, {$0})
print("(pointer)")

swift指针参考:http://www.cocoachina.com/articles/26419
https://blog.csdn.net/GuoHeroes/article/details/81043747

上一篇下一篇

猜你喜欢

热点阅读