NSString *pointer = @"test";
NSString *address = [NSString stringWithFormat:@"%p",pointer];
id retrievedObject;
sscanf([address cStringUsingEncoding:NSUTF8StringEncoding], "%p", &retrievedObject);
/// this requires a "0x" formatted hex string
ptr = [ptr hasPrefix:@"0x"] ? ptr : [@"0x" stringByAppendingString:ptr];
uintptr_t hex = strtoull(ptr.UTF8String, NULL, 0);
id gotcha = (__bridge id)(void *)hex;
https://stackoverflow.com/questions/29577606/how-to-dereference-an-objective-c-object-via-its-pointer-memory-address
int sscanf( const char* , const char*, ...);
int sscanf(const char *buffer , const char *format , [argument ]...);
buffer 存储的数据
format 格式控制字符串
argument 选择性设定字符串
sscanf会从buffer里读进数据,依照format的格式将数据写入到argument里
链接:https://www.jianshu.com/p/67e50d4d4872
网友评论