Dark Horse programmer _ios Development _OBJECTIVE-C Learning Notes _foundation Framework common structure

Source: Internet
Author: User

Introduction to the 1.Foundation Framework 1.1 use Foundation to:

* Create and manage collections, such as arrays and dictionaries

* Access images and other resources stored in the app

* Create and manage strings

* Submit and receive notifications

* Create date and Time objects

* Automatic discovery of devices on IP networks

* Operation URL Flow

* Execute Asynchronous code

Note: The foundation framework is imported by default so you don't have to deliberately import one of the necessary frameworks

Some frequently-contacted structures in the 1.2Foundation framework

Since the elements in the struct member variables of the object in the OBJECTIVE-C program cannot be accessed directly from the object, we have to modify the elements of the object struct member variable by creating a new struct and assigning the value as a whole.

While the iOS interface design Framework Uikit Many of the operations of the class such as UIView are through the structure, so the knowledge and operation of the structure need us to master

*cgpoint Structural Body

1.2.1 is defined as follows:

    1. Double   struct cgpoint {      //double type       cgfloat y;   };    struct Cgpoint Cgpoint;  


1.2.2CGPoin can be used to represent a positional coordinate

1.2.3 commonly used to set the location of the method:

Cgpoint point = Cgpointmake (///iOS development often uses  = = Cgpointmake (0 ,0);

1.2.4 The method of judging whether two points are equal

    1. BOOL p =  cgpointequaltopoint (cgpointmake (ten), Cgpointmake (Ten));  

*cgsize Structural Body

1.2.5 is defined as follows:

    1. struct cgsize {   cgfloat width;   CGFloat height;   };    struct Cgsize cgsize;

1.2.6 function that can be used to represent a rectangle, an element that occupies the range of the screen

1.2.7 commonly used to set the scope of the method:

Cgsize size = Cgsizemake (+); Cgsizezero= =  Cgsizemake (00);

1.2.8 How to determine whether two size is equal

    1. BOOL s = cgsizeequaltosize (cgsizemake), Cgsizemake (+);

*cgrect Structural Body

1.2.9 is defined as follows:

    1. struct CGRect {   cgpoint origin;   Cgsize size;   };    struct CGRect CGRect;

1.2.10 function, this structure covers the basic position of the point and occupies the size of the screen, you can determine the specific location and range of the screen, the exact expression can represent a rectangle

So we often use this struct when we manipulate the Bound,frame property of the object of UIView and its subclasses.

   Note: Because the elements in the object structure cannot be accessed directly, we can only achieve the purpose of modifying the elements in the struct body by creating a struct and assigning values

For example, when we want to modify the position and size of a uiview, we cannot directly modify the frame element in the UIView object, such as X, Y. Instead, you need to create a cgrect struct and then assign the whole value to operate.

The method of setting structure body value commonly used in 1.2.11

    1. CGRect r1 = CGRectMake (02);    = {{0,0},{, +}};   = {P1,S1}; //

1.2.12 A method that determines whether a rectangle contains a point

BOOL r = Cgrectcontainspoint (CGRectMake (00), Cgpointmake ( 201));

5. During the development process, we often look at the values of several structures, which are generally converted to strings:

  1. // frequently viewed in development: general practice converts all data into strings      NSString *String = Nsstringfrompoint (p1);       *string1 = nsstringfromsize (s1);       *string2 = Nsstringfromrect (r1);      NSLog (@ "p1:%@",string);      NSLog (@ "S1:%@", string1);      NSLog (@ "R1:%@", string2);   

Black Horse programmer _ios Development _OBJECTIVE-C Learning Notes _foundation Framework common structure

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.