Dark Horse programmer------<a href= "http://www.itheima.com" target= "blank" >java training, Android training, iOS training,. NET training </a>, look forward to communicating with you! -------
The foundation framework is the underlying framework for iOS development, which includes string, collection, date, time, and other basic classes
void Test () { //define Date This struct type struct date{ int year; int month; int day; } Define struct variable struct Date d = {~, +}; D.day = 6;} void Test1 () { typedef struct { int year; int month; int day; } MyDate; MyDate is the struct mydate d = {2013, 07, 27};}
Nsrange, Cgrange :
The source code is:
typedef struct _NSRANGE {
Nsuinteger location; Start position
Nsuinteger length; Number of elements
} Nsrange;
Three ways to create a Nsrange variable
Way One:
Nsrange Reange;
Reange.location = 7;
Range.length = 3;
Way two:
Nsrange range = {3, 7}
or Nsrange range = {. location=7,. length = 3};
Way three (most commonly used):
A shortcut function provided by the Foundation framework Nsmakerange
Nsrange range = Nsmakerange (7,3);
How to use:
void Range () {
Nsrange range = Nsmakerange (8, 10); struct is not an object
NSLog (@ "Location:%zi", range.location); $z unsigned
Convert Range to String
NSString * str = nsstringfromrange (range);
NSLog (@ "%@", str); Printing: {8, 10}
}
Nspoint, Cgpoint:
void Point () {
Nspoint p; can also be written cgpoint
Way One
p.x = 1;
P.Y = 10;
Way Two
p = nsmakepoint (1,9);
or P = cgpointmake (1, 9); (The most common way)
Programming strings for the NSPOINT structure
NSString *str = Nsstringfrompoint (p);
NSLog (@ "%@", str); Print {1, 10};
}
nssize, cgsize:
void Size () {
Nssize size;
Way One
Size.width = 100;
Size.Height = 90;
Way Two
Size = Nsmakesize (100,90);
or size = Cgsizemake (100, 90);
NSString * str = nsstringfromsize (size);
NSLog (@ "%@", str); Print {100, 90}
}
Nsrect, CGRect:
Include location (origin), dimension (size)
void Rect () {
Nsrect rect;
rect.origin.x = 10;
RECT.ORIGIN.Y = 11; Rect.origin = {10, 11} is not allowed to be used this way
Rect.size.width = 100;
Rect.size.height = 90;
You can also assign a value using the following method
Rect = Cgmakerect (10, 11, 100, 90);
NSString * str = nsstringfromrect (rect);
NSLog (@ "%@", str); Print {{10, 11},{100, 90}}
}
26-Dark Horse programmer------OC Language Learning Note---Foundation01