Common object-c framework struct

Source: Internet
Author: User

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

 

 



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.