@property (assign) CGRect rect;
CGrect
is a struct, not an NSObject
, so you cannot send message to it (like retain
).
You're full setup then will be something like:
// MyClass.h
@interface MyClass : NSObject
{
CGRect _rect;
}
@property (assign) CGRect rect;
and
// MyClass.m
@implementation MyClass
@synthesize rect=_rect;
@end
So basically you can then do something like:
MyClass *myClass = [[MyClass alloc] init];
myClass.rect = CGRectMake(0,0,0,0);
The synthesize directive basically makes two methods (getter/setter) for you "behind the scenes"; something like...
- (CGRect)rect;
- (void)setRect:(CGRect)value;
I usually add a "_" to my instance vars. The rect=_rect
is telling the compiler to modify the _rect instance var whenever the rect property is "called."
Have a read through these tutorials on Theocaco. He explains what the @synthesize(r) is doing behind the scenes.