26-Dark Horse programmer------OC Language Learning Note---Foundation01

Source: Internet
Author: User

Dark Horse programmer------<a href= "http://www.itheima.com" target= "blank" >java training, Android training, iOS training,. NET training </a>, look forward to communicating with you! -------

The foundation framework is the underlying framework for iOS development, which includes string, collection, date, time, and other basic classes

void Test () {  //define Date This struct type  struct date{     int year;      int month;     int day;  }  Define struct variable   struct Date d = {~, +};   D.day = 6;} void Test1 () {    typedef struct {       int year;        int month;       int day;    } MyDate;     MyDate is the struct     mydate d = {2013, 07, 27};}

  

Nsrange, Cgrange :

The source code is:
typedef struct _NSRANGE {
Nsuinteger location; Start position
Nsuinteger length; Number of elements
} Nsrange;

Three ways to create a Nsrange variable
Way One:
Nsrange Reange;
Reange.location = 7;
Range.length = 3;

Way two:
Nsrange range = {3, 7}
or Nsrange range = {. location=7,. length = 3};

Way three (most commonly used):
A shortcut function provided by the Foundation framework Nsmakerange
Nsrange range = Nsmakerange (7,3);

How to use:
void Range () {
Nsrange range = Nsmakerange (8, 10); struct is not an object
NSLog (@ "Location:%zi", range.location); $z unsigned

Convert Range to String
NSString * str = nsstringfromrange (range);
NSLog (@ "%@", str); Printing: {8, 10}
}

Nspoint, Cgpoint:

void Point () {
Nspoint p; can also be written cgpoint
Way One
p.x = 1;
P.Y = 10;
Way Two
p = nsmakepoint (1,9);
or P = cgpointmake (1, 9); (The most common way)

Programming strings for the NSPOINT structure
NSString *str = Nsstringfrompoint (p);
NSLog (@ "%@", str); Print {1, 10};
}

nssize, cgsize:

void Size () {
Nssize size;
Way One
Size.width = 100;
Size.Height = 90;

Way Two
Size = Nsmakesize (100,90);
or size = Cgsizemake (100, 90);

NSString * str = nsstringfromsize (size);
NSLog (@ "%@", str); Print {100, 90}
}

Nsrect, CGRect:
Include location (origin), dimension (size)

void Rect () {
Nsrect rect;
rect.origin.x = 10;
RECT.ORIGIN.Y = 11; Rect.origin = {10, 11} is not allowed to be used this way

Rect.size.width = 100;
Rect.size.height = 90;

You can also assign a value using the following method
Rect = Cgmakerect (10, 11, 100, 90);

NSString * str = nsstringfromrect (rect);
NSLog (@ "%@", str); Print {{10, 11},{100, 90}}
}

26-Dark Horse programmer------OC Language Learning Note---Foundation01

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.