假设存在对象:
class testClass
{
public:
string myCode;
}
封装示范代码:
testClass* test = new testClass();
test.myCode = "Hello NSValue";
NSValue* value = [NSValue valueWithBytes:(voide*)test objcType:@encode(testClass)];
return value;
解封示范代码:
testClass* testRecive = new testClass();
[value getValue:testRecive];
printf("%s",testRecive.myCode.c_str());
用途:
用来把C/C++的对象(结构体)封装成objC的对象NSValue,便于在objC调用,以及使用NSArray、NSDictonary等数据结构传递。
class testClass
{
public:
string myCode;
}
封装示范代码:
testClass* test = new testClass();
test.myCode = "Hello NSValue";
NSValue* value = [NSValue valueWithBytes:(voide*)test objcType:@encode(testClass)];
return value;
解封示范代码:
testClass* testRecive = new testClass();
[value getValue:testRecive];
printf("%s",testRecive.myCode.c_str());
用途:
用来把C/C++的对象(结构体)封装成objC的对象NSValue,便于在objC调用,以及使用NSArray、NSDictonary等数据结构传递。