Day17 oc Foundation structure

structure

NSRange (including location and length, which can represent the position and length of a string in a string, elements in an array, etc.)

 

//Assignment by structure (not commonly used)
NSRange r1 = {1,2} ;
NSRange r2 = {.location = 1,.length = 2};
// use the following method
NSRange r3 = NSMakeRange(1,2);
NSRange r4 = [str rangeOfString:@"aaa"];//Find the range of a string in str, if not found, length = 0, location = NSNotFound = -1

 

NSPoint/GCPoint, CGPoint cross-platform in development

CGPoint p1 = NSMakePoint(1,2);
NSPoint p2 = CGPointMake(1,2);//Common 
NSString *str = NSStringFromPoint(p1);//The structure is converted to a string and printed

NSSize/CGSize, the same

 

NSRect/CGRect (including CGPoint, CGSize)

CGRect r1 = CGRectMake(0,0,100,50);
CGRect r2 = {{0.0}, {50.50}};
CGRect r3 = {p1,p2};
CGRect r4 = {CGPointZero, CGSizeMake (50,50)}; // Origin

 The origin of the iPhone coordinates is in the upper left corner, down is y, and right is x

ps: CG adds CoreGraphics framework

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326924388&siteId=291194637