OC High Efficiency 52: (ii) in the header file of the class as few as possible to refer to other header files

Source: Internet
Author: User

////  eocperson.h//   OC High Efficiency 52: Refer to other header files as few as possible in the header file of the class////  created by zoujie on 15/10/8.//   COPYRIGHT&NBSP;?&NBSP;2015 year  zoujie. all rights reserved.//#import  <foundation/ foundation.h>//#import   "EOCEmployer.h" @class  eocemployer;//forward to declare the class, the time to introduce the header file as far as possible, only to determine the need to introduce If the EOCEmployer.h is introduced into EOCPerson.h, all the contents of EOCEmployer.h will be introduced as soon as the EOCPerson.h is introduced. The forward declaration also solves the problem of two classes referencing each other @interface eocperson : nsobject@property  (nonatomic,copy)  NSString  *firstName; @property   (nonatomic,copy)  NSString *lastName; #pragma  mark -essentials/*  *  do not introduce a header file unless it is necessary. In general, you should use forward declarations in the header file of a class to refer to other classes and to introduce which classes of header files in the implementation file. Doing so minimizes the coupling between classes.   * sometimes cannot use forward declarations, such as declaring a class to follow a protocol. In this case, try to move the "this class follows an agreement" declaration to "Class-continuation classification". If not, put the protocol in a single header file and introduce it.   */@property   (nonatomic,strong)  EOCEmployer *employer; @end 
eocperson.m//oc High Efficiency 52: As few as possible in the header file of the class refer to other header files////Created by Zoujie on 15/10/8.//Copyright? 2015 Zoujie. All rights reserved.//#import "EOCPerson.h" #import "EOCEmployer.h" @implementation eocperson@end
eocemployer.h//oc High Efficiency 52: As few as possible in the header file of the class refer to other header files////Created by Zoujie on 15/10/8.//Copyright? 2015 Zoujie. All rights reserved.//#import <Foundation/Foundation.h> @class eocperson @interface eocemployer:nsobject-(void ) AddEmployee: (Eocperson *) person;-(void) Deleteemployee: (Eocperson *) person; @end
eocemployer.m//oc High Efficiency 52: As few as possible in the header file of the class refer to other header files////Created by Zoujie on 15/10/8.//Copyright? 2015 Zoujie. All rights reserved.//#import "EOCEmployer.h" #import "EOCPerson.h" @implementation eocemployer@end


OC High Efficiency 52: (ii) in the header file of the class as few as possible to refer to other header files

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.