Beginner Learning iOS

Source: Internet
Author: User

The difference between @interface and @property declaration variables in Object-c objective-c language keywords, used with @synthesize pairing. xcode4.5and later versions, @synthesize can omit the function: Let the compiler automatically write a method declaration with the same name as the data member, eliminating the declaration of the read-write method.

What is the difference between these two ways?

1. If you define variables only in @interface, the variables you define can only be accessed in the current class, not in other classes, and variables declared with @property may be accessed externally.

2. Using @property to declare variables, you can use the "self. Variable name" method to read and write variables. And the way to use @interface is not possible.

It is common to define a variable in @interface brackets and repeat it with @property, which is not actually necessary. It is enough to use @property and @synthszie, because a variable is created when a read-write method of this property is synthesized with @synthsize.

Http://www.cnblogs.com/letmefly/archive/2012/07/20/2601338.html

@interface: An interface that provides a public description of the class, which contains the required information to use the class, and, after compiling this part, can use the object and invoke the class method.

@implementation: Implementation, tells the compiler how to make the class work, implements the method declared in the interface.

The code is divided into two parts, interface and implementation,

The interface section contains: @interface directives, common struct definitions, enum constants, @defines and extern global variables, and so on.
Implement partial inclusions: @implementation directives, definitions of global variables, private structs, and so on.


#import: Import Header File: Header file contains element declarations (such as struct, symbol constants, function prototypes, etc.), #import同c语言中的 # include similar, the difference is that in C, you typically use the #ifdef command to avoid a header file that contains another file, and # Impurt can guarantee that header files are included only once.

The angle bracket statement is used to import the system header file (read-only), and the quoted statement is used to import the project local header file (readable).

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.