I am having trouble with something relatively simple (or so I think so), but I can't figure out what I need to do to make it right. So here is the deal... I have a block of code that I use frequently throughout my application so I thought I should just make it into a function. So I did so and the function takes nothing and returns a (NSString *) and I try assigning the returned value to a temporary NSString * that the label will be assigned to, but I get this warning:
So I think I know what I need to do, I need to have the function return the string itself rather than a pointer to the string, but I don't know how to do that. Google hasn't been much help. Here is my code:
Thanks in advance for any help whatsoever.
Code:
/!\ warning:'NSString' may not respond to '-makeMinsToGo' (Messages without a matching method signature will be assumed to return 'id' and accept '...' as arguments.)
Code:
//function:
- (NSString*) makeMinsToGo {
/***...code...(showing last bit of function code)***/
NSString *minsToGoLabelText = [[[NSString alloc] initWithString:
[timeToGoFormatter stringFromDate:dateComponentsTimeToGo]] autorelease];
return minsToGoLabelText;
}
//makes function call in this code block
NSString *temp = [[NSString alloc] initWithString:[temp makeMinsToGo]];
//previously mentioned warning shows up right here
minsToGo.text= temp;
//[minsToGo.text makeMinsToGo]; //this doesn't work either
[temp release];
Thanks in advance for any help whatsoever.