Hey I have a really simple question that needs more of just an explanation than a debug, but I have seen in the interface definitions for many class objects the keywords "@package", "@private", "@public", and then even weirder "struct {...}". I have been able to make complete programs without using any of the aforementioned, so I was hoping someone could explain to me the significance of those keywords.
Thanks
EDIT:
Wait, I understand now that the restictions of each declaration but why would you ever need to use them? And can you clarify what "struct {...}" means and how I use it? Thanks again :D
Concerning Package, your Question is answered here in detail: What does the @package directive do in Objective-C?
struct is a C construct that lets you access multiple data types under a single name.
@private restricts access to variables to the use by just this class
@protected restricts access to variables to the use by just this class and inheriting classes ( default in Obj-C classes)
@package restricts access to variables to the use by the framework
@public lets everyone acces this variable
Edit:
struct person { /* declares struct person */
int age;
float weight;
char name[25];
} adam;
struct person joe;
joe.age = 23; /* add values */
joe.weight = 147.8;
Concerning the restriction, its good OO Practice to restrict access to variables, known as encapsulation http://en.wikipedia.org/wiki/Encapsulation_%28object-oriented_programming%29
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.