Simple sharing under, hope that Daniel more guidance maze, gradually revise, perfect insufficient support. For reference, please also understand
#import <Foundation/Foundation.h>
typedef struct{//c-Structural Body
int year;
int month;
int day;
}date;
void text () {
Date mydate; To define a struct-body variable
Date date={2016,8,20};
Char *[email protected] (Date); Generate a corresponding type description string based on struct type
void* represents any pointer. This is going to be the address of the struct &date
Nsvalue *val=[nsvalue value:&date Withobjctype:type];
[Val Objctype]; Remove type description string
[Val getvalue:&mydate]; Remove the packaged structure
NSLog (@ "%i-%i-%i", mydate.year,mydate.month,mydate.day); . Represents an Access member
}
int main (int argc, const char * argv[]) {
@autoreleasepool {
#pragma mark NSNumber common methods
Can only be packed with numbers, cannot package structures, and does not support automatic unpacking of packages
NSNumber *num=[nsnumber Numberwithint:10];
wrapping int Type 10 to a NSNumber object
Nsmutablearray *array=[nsmutablearray Array];
[Array addobject:num]; Adding values to the array
NSNumber *num1=[array Lastobject];
Removed is still a NSNumber object, does not support automatic unpacking
int NUMBER=[NUM1 Intvalue]; Convert NSNumber to int type
[Email protected]; quickly wrap digital objects
#pragma mark Nsvalue Common methods
Wrapper class, Nsvalue is the parent class of nsnumber, can wrap any value
Cgpoint Point=cgpointmake (10, 10);
Nsvalue *value=[nsvalue Valuewithpoint:point];
Wrapping a struct as an object
[Array Addobject:value]; Add Value
Nsvalue *v1=[array Lastobject];
Cgpoint P1=[v1 Pointvalue]; Remove the value put in
BOOL Re=cgpointequaltopoint (Point, p1); Comparison of Judgments
Nsvalue *[email protected] ' a '; Fast wrapper character, print out ANSCII code: 97
Text ();
}
return 0;
}
Simple knowledge about NSNumber & Nsvalue's methodology