Objective-C-attributes and member variables are different in. H files and. m files,
Differences between attributes and member variables in. H files and. m Files
Attribute declaration in. h file is different from in. m file. The difference is:
Attributes declared in the. h file. The external class can be called through "class instance. Attribute,
But it cannot be declared in. m. The methods for obtaining and setting can only be implemented through setValue: forKey and valueForKey.
Member variables have three permissions: @ private, @ protected, and @ public. in the m file, it is equivalent to the @ private permission, and The subclass cannot be accessed. After verification, the permission modification is also invalid. In the. h file, the default permission is @ protected, which can be accessed by subclass and modified by permission. Because of the access permission pointer to the. h file .. The member variable in the H file, called by an external class, is the same as that in C ++.
From: http://blog.sina.com.cn/s/blog_68f368050101eop8.html
@ Interface is extension ).
It is designed to solve two problems,
1. Define private methods.
Second, implement the public readonly and private readwrite property (meaning that an attribute defined in the h header file is readonly for external use, but it is expected to be readable and writable within the class, therefore, you can redefine this attribute as readwrite in the @ interface section of the m source file. In this case, this attribute is read-only externally and read/write internally ).
Third, you can declare the variables and attributes in this part. However, the declared variables, attributes, and methods are private and can only be accessed by the current class, which is equivalent to private.