As a second answer, I am trying to understand your problem through all your recent questions.
At the beginning, there was a C function returning a pointer to a NSString
object:
NSString * myfunc( int x )
{
... // Do something with x
NSString * myString = @"MYDATA";
... // Do something with myString
return myString;
}
Then, you wanted to add in that function some code about an UIImage
object:
image1.image = [UIImage imageNamed:@"image1.png"];
You were advised to convert the function to a method. If you want to access .image
instance variable, this method has to belong to the class of image1
object (let's say this is AlanImage
class). Something like this:
@interface AlanImage : NSObject {
UIImage image;
}
- (NSString *) myfuncWithParam: (int) x;
@end;
@implementation AlanImage
- (NSString *) myfuncWithParam: (int) x
{
NSString * myString = @"MYDATA";
image = [UIImage imageNamed:@"image1.png"];
return myString;
}
@end
Third, you didn't know what was the receiver of the method. My investigations tend to lead to your image
object as a good candidate:
aNiceString = [image myfunc:aNiceInteger];
Finally (this question), not getting a satisfying answer, you reworded your third question, with success this time as it happens.
I am curious to get a more complete view of your project in order to give you some hints. Anyway, it seems that you are learning Objective-C and object oriented concepts: congratulations and stay motivated!