Hey guys, check this out. I have a function that treats for me a string. No matter what it does, i just want to knwo if is possible to this function return the result for the place that it was executed. I mean, check this:
[self priceFormat:@"1"];
priceLabel.text = price;
-(void) priceFormat:(NSString*)price {
price = @"2";
}
I just want to my function treats the string and return it to the same place that it was executed.
Thanks!
Three ways to do this
Way one, using a pointer
Wat two, using an instance variable
What you might want instead is an ivar. In the interface (most often the
hfile) of your class:and in the implementation (the
mormmfile):I have created an example of this here.
If you want the price to be available to other objects as well (not just
self), you might want to create a property for it and synthesize it. Then useself.price = @"2";instead. More on this here: http://MacDeveloperTips.com/objective-c/objective-c-properties-setters-and-dot-syntax.htmlJust make sure you make it a
copyproperty (NSString in use)!Way three using
returnNote, that you can also return directly from a method: