Dark Horse Programmer--the essence of class

Source: Internet
Author: User

------Java Training, Android training, iOS training,. NET training, look forward to communicating with you! The---class itself is also an object, which is a class-type object, referred to as the *p = [[Person alloc] init]; Person *P1 = [[Person alloc] init];//gets the class object in memory Class C = [P class]; Class C1 = [P1 CLASS];C==C1//Get Class object in memory Class C2 = [Person Class];c==c1==c2person * p = [C2 new]//by default, when using NSLog and%@ output objects, the result is :< class Name: Memory address &GT;//1, will call the object P-description method//2, get the-description method return value (NSString *) display to the screen//3,-description method by default returns "class name + Memory Address "NSLog (@"%@ ", p); To output the details of an object, override it in the object implementation only-DescriptionMethod (The ToString method in Java)-(NSString *) description//decidesInstance ObjectThe output {return [NSString stringwithformat:@ "age=%d,name=%@", _age,_name];} + (NSString *) description//decisionClass ObjectOutput, if not overridden, the default output when the class name of the class object {return @ "abc";}//When the program starts, it loads all the classes in the project once, the class is loaded and the +load method is called (the Load method of the class is called first, and then the load method of the category is called) + (void) load{}//when this class is first used, the +initialize method + (void) initialize{} classification can also be called by the load and initialize methods, and the Load method is loaded. If there are initialize methods in both classes and classifications, then the Initialize method in the class is called the first time, and no +initialize 1 in the class is invoked, and when the program starts, all classes and classifications in the project are loaded. Moreover, the +load method is called without various types and classifications. Only 2 is called once, when a class is first used, the +initialize method () 3 of the current class is called, the parent class is loaded, the child class is loaded (the +load method of the parent class is called first, the +load method of the subclass is called) First initializes the parent class, and then initializes the child class (the parent class's + Initialize method, then call +initialize of subclass)

Dark Horse Programmer--the essence of class

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.