Common object-c framework struct
The Foundation framework defines common struct types, and the struct types are defined by object-c: Common NSSRange, NSPoint, NSSize, NSRect, etc.
1. Create a range struct in nsange.
Method: NSMakeRange (parameter 1, parameter 2 ). Location and length.
Ii. collection data type.
1. NSPoint creates a vertex.
Method: NSMakePoint (parameter 1, parameter 2 ). X and y.
2. NSSize creation length and width.
Method: NSMakeSize (parameter 1, parameter 2 ). Width and height.
The following is my test and learning code:
/// FoundtionOftenStruct. h // Array_01 // Created by selfimprovement on 15-6-4. // Copyright (c) 2015 FoundationFramework. all rights reserved. // # import
@ Interface FoundtionOftenStruct: NSObject {} // declare a dynamic method without returning the value-(void) testnsange; // nsange indicates a range-(void) testNsPoit; // NSPoint indicates a vertex-(void) testNsSize; // NSSize indicates the size-(void) testNsRect; // NSRect indicates the rectangle @ end
/// FoundtionOftenStruct. m // Array_01 // Created by selfimprovement on 15-6-4. // Copyright (c) 2015 FoundationFramework. all rights reserved. // # import "FoundtionOftenStruct. h "@ implementation FoundtionOftenStruct-(void) testnsange {NSString * strRange = @", "; nsange range1 = [strRange rangeOfString: @", 2, "]; if (range1.length> 0) {NSLog (@" range is % @ ", NSStringFromRange (range1) ;}}-(void) testNsPoit {NSPoint point = CGPointMake (10, 5); NSLog (NSStringFromPoint (point);}-(void) testNsSize {NSSize size = CGSizeMake (10, 5 ); NSLog (NSStringFromSize (size);}-(void) testNsRect {NSRect rect = CGRectMake (1, 3, 10, 20); NSLog (NSStringFromRect (rect);} @ end
//// Main. m // Array_01 // Created by selfimprovement on 15-6-1. // Copyright (c) 2015 FoundationFramework. all rights reserved. // # import "FoundtionOftenStruct. h "# import
Int main (int argc, const char * argv []) {@ autoreleasepool {FoundtionOftenStruct * rangeStruct = [foundtionofstruct alloc]; rangeStruct. testnsange; rangeStruct. testNsPoit; rangeStruct. testNsRect; rangeStruct. testNsSize;} return 0 ;}
Test results:
15:12:56. 567 Array_01 [914: 303] range is {3, 3}
15:12:56. 582 Array_01 [914: 303] {10, 5}
15:12:56. 586 Array_01 [914: 303] {1, 3 },{ 10, 20 }}
15:12:56. 587 Array_01 [914: 303] {10, 5}
Program ended with exit code: 0