1. After the Xcode tool is installed, it will bring with it the frameworks that are commonly used in development. The storage address path is:
/Applications/Xcode. app/Contents/Developer/Platforms/iPhoneOS. platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/
2. In iOS development, the Foundation framework is the most basic framework. The Foundation framework contains common classes and data types, such as struct and enumeration.
3. To use the Foundation framework, you only need to include its primary header file <Foundation/Foundation. h>. The header file contains all header files in the framework.
4. Structures commonly used in the Foundation framework:
Nsange, NSPoint \ CGPoint, NSSize \ CGSize, NSRect \ CGRect
(1) The general usage of struct is as follows:
Date date = {,, Date date2 = {.year=, .day=, .month=};
(2) nsange struct: used to describe the range
- View the officially defined nsange
typedef NSUInteger length; } NSRange;
- Brief description and usage of nsange
NSRange r1 = {, NSRange r2 = {.location = , .length = NSRange r3 = NSMakeRange(, );
- Find the nsange of certain characters in the NSString class object in the entire class Object
*str =
NSRange range = [str rangeOfString:
NSLog(,range.location,rang.length);
# define CGFLOAT_TYPE typedef typedef CGPoint NSPoint;
CGPoint point = NSMakePoint(, ); NSPoint point2 = CGPointMake(, );
(3) NSSize struct: Describes the size (width and height) of the element, and definesSimilar to NSPoint, we will not repeat it again. The general usage is as follows:
CGSize size = NSMakeSize(, = CGSizeMake(, );
(4) CGRect struct: used to describe the position (CGPoint) and size (CGSize) of an element.
- Officially defined CGRect
CGSize size; };
typedef CGRect CGRect;
CGRect rect = CGRectMake(, , , NSRect rect2 = NSMakeRect(, , , );
CGRect rect = {{,},{, NSPoint point = CGPointMake(, = CGSizeMake(, = CGRect rect3 = {CGPointZero,CGSizeMake(, )};
(5) simulate the implementation process of the CGRectMake Function
rect.origin.x == rect.size.width ==
5. How to quickly view values in struct
- Method 1: extract values from struct in sequence
NSRect rect = CGRectMake(, , , NSLog(
NSRect rect = CGRectMake(, , , NSString *strRect = NSLog(,strRect);
6. Common struct Functions
- Common struct functions are under the CoreGraphics. framework.
BOOL pointIsEqual = CGPointEqualToPoint(CGPointMake(, ), CGPointMake(, BOOL sizeIsEqual = CGSizeEqualToSize(CGSizeMake(, ), CGSizeMake(, CGRect rect1 = {{,},{, NSPoint point = CGPointMake(, = CGSizeMake(, = BOOL rectIsEqual = BOOL isContent = CGRectContainsPoint(rect1, CGPointMake(, ,isContent);