Dark Horse programmers-the nature of classes, dark horse programmers ---

Source: Internet
Author: User

Dark Horse programmers-the nature of classes, dark horse programmers ---
------ Java training, Android training, iOS training, and. Net training. We look forward to communicating with you! --- The Class itself is also an object of the Class type, referred to as the Class Object Person * p = [[Person alloc] init]; person * p1 = [[Person alloc] init]; // obtain the Class object in the memory class c = [p Class]; class c1 = [p1 Class]; c = c1 // obtain the Class object in the memory class c2 = [Person Class]; c = c1 = c2Person * p = [c2 new] // by default, when an object is output using NSLog and % @, the result is: <Class Name: memory address> // 1, the-description method of object p is called // 2, the returned value of the-description method (NSString *) is displayed on the screen // 3. The default value returned by the-description method is "class name + Memory Address" NSLog (@ "% @", p); to output the detailed information of an object, only Write-description method (toString method in java)-(NSString *) description // determines the output result of the Instance Object {return [NSString stringWithFormat: @ "age = % d, name = % @ ", _ age, _ name] ;}+ (NSString *) description // determines the output result of the class object. If not overwritten, by default, the class name {return @ "abc";} // when the program starts, all classes in the project will be loaded, after the class is loaded, the + load method is called (the load method of the class is called first, and then the load method of the classification is called) + (void) load {} // when this class is used for the first time, the + initialize method + (void) initialize {} class can also be used by the load and initialize methods, the load method is called after the load method is loaded. If both classes and classes have ini Tialize method, the initialize method in the category will be called when this class is used for the first time. + initialize 1 in the class will be called only when the program is started, all classes and categories in the project will be loaded, and the + load method without all types and categories will be called after recording. 2 is called only once. When a class is used for the first time, the + initialize method () 3 of the current class is called. The parent class is loaded first, then load the subclass (first call the + load method of the parent class, then call the + load method of the subclass) First initialize the parent class, and then initialize the subclass (first call the + initialize method of the parent class, + initialize)

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.