I need access address of property but have problem. example code is
@interface Rectangle : NSObject
{
SDL_Rect wall;
SDL_Rect ground;
}
@property SDL_Rect wall;
@property SDL_Rect ground;
@end
@implementation Rectangle
@synthesize x;
@synthesize y;
@end
@interface Graphics : NSObject
{
int w;
int h;
}
-(void) drawSurface
@end
@implementation Graphics
-(void) drawSurface
{
Rectangle *rect = [[Rectangle alloc] init];
SDL_BlitSurface(camera, NULL, background, &rect.wall);
}
@end
&rect.x is Address of property expression requested
As the comments suggest, you cannot take the address of a property. A property is really just a promise that the object in question provides accessors for some value. The value itself may or may not even exist in an instance variable. For example, the getter for a property called
fullName
might generate the required value on the fly by concatenating the values offirstName
andlastName
properties.Since you need to pass the address of a
SDL_Rect
intoSDL_BlitSurface()
, you could first copy the necessary property into a local variable, and then pass the address of that variable:If you need to preserve the value left in
wall
after the call toSDL_BlitSurface()
, copy it back again after the call: