Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Jules2010

macrumors member
Original poster
Apr 7, 2010
34
0
Heres my function which xcode likes.
Code:
- (float) getLength:(NSString *)str
{
	float ret = 0.0;
	
	return ret;
}

Heres the calls I've tried to that function
Code:
lbl.text = self.getLength:@"1";
lbl.text = [NSString stringWithFormat:@"%i. ", self.getLength:@"1"];

I've tried similar variations but xcode doesn't like it.

I get this error.
error: request for member 'getLength' in something not a structure or union

Help!

TIA
 
The . syntax can only be used for properties. You have defined a method (not a function) so have to make a call to a method.

Code:
[self getLength:@"1"];

Also I do not expect that setting the text property of a label (which is a NSString) to a float would work.

I suggest you need to stop writing code and sit down with the Objective-C Introduction and cup of coffee/tea/beer.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.