比较简单,直接上代码:
#import <Foundation/Foundation.h>
typedef struct {
int year;
int month;
int day;
}MyDate;
int main(int argc, const char * argv[]) {
@autoreleasepool {
// insert code here...
NSNumber *n1 = [NSNumber numberWithInt:1];
NSArray *arr = [NSArray arrayWithObjects:n1, nil];
NSNumber *n2 = [arr lastObject];
NSLog(@"%@",n2);
CGPoint p = CGPointMake(100, 20);
NSValue *v1 = [NSValue valueWithPoint:p];
NSArray *arr2 = [NSArray arrayWithObjects:v1, nil];
NSValue *v2 = [arr2 firstObject];
CGPoint p2 = [v2 pointValue];
NSLog(@"%f %f",p2.x,p2.y);
MyDate d1 = {2015,9,14};
NSValue *v3 = [ NSValue valueWithBytes:&d1 objCType:@encode(MyDate)];
NSMutableArray *arr3 = [NSMutableArray arrayWithObjects:v3, nil];
NSLog(@"%@",arr3);
MyDate tmd;
[v3 getValue:&tmd];
NSLog(@"%d %d %d",tmd.year,tmd.month,tmd.day);
}
return 0;
}