"Objective-c Study record" 30th day

Source: Internet
Author: User

NSDate class

NSDate is the class that represents the date in the foundation framework, which is used to get the current time, which includes: Month Day, time division, 0 timezone, and time zone. Note that it must be 0 time zone!

Common methods:

1.datewithtimeinterval:sincedate:. The first parameter is a floating-point number that represents seconds, the second argument is a variable of type nsdate, and the method returns a NSDate object whose value is the time that the second parameter represents and the time it takes to get the number of seconds. For example, instantiating a NSDate object represents the current time, the first parameter fills the 24*60*60 (the number of seconds in a day), which will get the nsdate variable at this time tomorrow.

2.timeintervalsincedate:. The argument is the NSDate type, which returns a floating-point number of type Nstimeinterval (double), representing how many seconds have elapsed since the time the parameter was given.

3.timeIntervalSince1970:. Indicates how many seconds have elapsed since January 1, 1970 (January 1, 1970 is the time of Birth of Unix).

NSDateFormatter class

The NSDateFormatter class is a date format class that works by NSDate objects with NSString objects.

Common methods:

1.Setdateformat:. Format the date display, such as: @ "Yyyy-mm-dd HH:mm:ss".

2.stringfromdate:. Converts a Date object to a String object.

3.datefromstring:. Converts a string object to a Date object.

Category (category)

Characteristics:

1. The class is a class that is internal to the system, or a class that does not have source code, and cannot add an instance variable

2. The added method becomes part of the original class, and subclasses can still use the

3. Class purpose file Fame original class name + file name

4. You can either add an instance method or add a class method

For example, add a sort method to the Nsarray class so that each Nsarray object can execute the sorting method directly.

Extension (Extension)

Characteristics:

1. Extensions appear for custom class extension functions

2. Above the class's. m file, use the @interface keyword to build the extension

3. In the extension, we can either declare a method or declare an instance variable or property

4. The newly added content belongs to the private part of this class

Protocol (PROTOCOL)

"Objective-c Study record" 30th day

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.