I have a question about methods and memory allocation in Objective-C
for example.
for setting an object in a class that has a NSString object as attribute
it should be fine.
for a normal type (c types, ex: int, double)
It should work;
but how about pointers?
I mean:
lets suppose I have a pointer to CF's structure RGBColor (which is the bitmap of a pic)
and then I set some values in the structure.
and then Try to pass is as an argument
is this ok?
or do I need to initialize oldBitmap also? (lets suppose is the first time I need to use it)
I am trying to pass a pointer to structure and then try to create a CGImageRef in order to show it using IKImageView. but the image shown is different from what i am trying to create.
help please.
for example.
for setting an object in a class that has a NSString object as attribute
Code:
-(void)setString:(NSString*)myString{
[myString retain]
[oldStrind release];
oldString = myString;
}
for a normal type (c types, ex: int, double)
Code:
-(void)setInt:(int)myint{
oldInt = myint;
}
but how about pointers?
I mean:
lets suppose I have a pointer to CF's structure RGBColor (which is the bitmap of a pic)
Code:
RGBColor *myBitmap = (RGBColor *)malloc (width*height*sizeof(RGBColor));
and then Try to pass is as an argument
Code:
(void)setBitmap(RGBColor *)myBitmap{
oldBitmap = myBitmap;
}
or do I need to initialize oldBitmap also? (lets suppose is the first time I need to use it)
I am trying to pass a pointer to structure and then try to create a CGImageRef in order to show it using IKImageView. but the image shown is different from what i am trying to create.
help please.