You have declared image
static UiImage *image;
Is that because you wish to initialise it once and thereafter refer to it - as a constant? If so, a good way to do this is to override the getter accessor method for image.
// foo.h
class foo {
UIImage* image_;
}
@property (nonatomic, retain) UIImage* image;
// foo.m
@synthesize image = image_;
-(UIImage*)image {
if (image_ == nil) {
//set the image here
image_ = [[UIImage alloc] init];
}
return image_
}
Then in client code, the first time you refer to foo.image it will be instantiated. The second and every other time you refer to it, it will already have a value.
// elsewhere in foo.m
UIImageView* fooImageView = [[UIImageView alloc] initWithImage:self.image];
// bar.m
UIImageView* barImageView = [[UIImageView alloc] initWithImage:foo.image];
See this SO answer also for reference.