可以啊,是这个意思么?
- typedef struct {
- char *name;
- int age;
- }Animal;
- int main(int argc, const char * argv[])
- {
- @autoreleasepool {
- Animal animal1 = {.name = "Dog", .age = 3};
- NSValue *v = [NSNumber value:&animal1 withObjCType:@encode(Animal)];
- NSArray *arr = @[v];
- Animal animal2;
- [arr[0] getValue:&animal2];
- NSLog(@"%s:%d", animal2.name, animal2.age);
- }
- return 0;
- }
复制代码 |