iphone - When should you NOT use the asterisk (*) when declaring a variable in Objective C -
I have just started learning the purpose and the asterisk is giving me some trouble as I see through the sample code I sometimes use it when declaring a variable and sometimes it does not happen. What is the "rule" for when it should be used, I thought it was something to do with the data type of the variable (Asterisk for the object data type is not required, for simple data types like int) though , I have declared the object data type like CGPEnt without asterisk? Is there a definite answer or what to do with it and what variables do you use for it?
Use.
For coco objects, then always declaring an indicator, so you always use the asterisks. You can not place the object in the variable; You always handle a pointer in the object.
For other things, it depends on whether the object will be included in the variable (in C mean) or a point-and-so-else object of the object. If the object should be included in the variable, then you do not declare it with an asterisk, because you are not putting an indicator in it, if there should be an indicator in it, you can declare it with asterisk.
You can also be an indicator for an indicator; As you might expect, there are many asterisks in it, for example, NSRect **
is an indicator for an NS structure (which is a structure, not a cocoa object).
I thought that with the data type of variable (the required data for the type of data type, not required for simple data types like int)
Sort is required for the esteric cocoa objects because you can handle pointers only for cocoa objects, objects never own themselves. But the rules of the announcement are not separate for cocoa items; They are exactly the same when you want an indicator variable so you use asterisk; You do not do this when you want a non-port variable.
The only exception, for the cocoa objects, is the only difference between general rules that you do not have permission to declare a variable that holds the object. This is why you never see a variable containing a cocoa object instead of a pointer: the compiler will not allow it.
However, do I see the object data type like CGPoint as well as the star?
CP point is a structure, not cocoa objects like, you can declare a variable that holds a CGPoint and not an indicator for any other.
Comments
Post a Comment