I’m trying to study Objective-C to create an iOS app with it. In Java, we can declare class-type variables in a single line, like this:
CustomClass first, second, third;
I tried to do the same in my interface in Objective-C using the @property tag:
@interface Rectangle : NSObject
@property XYPoint* origin, opposite;
// ...
@end
But this throws an error “Interface type cannot be statically allocated.” However, if I declare the two variables on separate property tags such as below, the error disappears.
@interface Rectangle : NSObject
@property XYPoint* origin;
@property XYPoint* opposite;
// ...
@end
Why is that? When I use my first approach with primitive types, it works. How come it doesn’t for class types? Also, unlike in other Q&As about the same error message, I didn’t miss putting the * after my type declaration.
You can do this:
EDIT: You synthesize them without the star like this:
/Søren