views:

67

answers:

2

I made a method like this:

-(void) doSomething:(NSString *)str
{

}

I call it like this

doSomething(foo);

It doesn't work.

+4  A: 

That is because doSomething is a method of an Objective-C class. The C syntax for function calls doesn't apply here and you need an instance to call it on, e.g.:

[instance doSomething:foo];

I strongly recommend to read through Apples The Objective-C programming language.

Georg Fritzsche
+5  A: 

The way that you call methods in objective c is like the following

[class method:parameter];

In your case, to call doSomething, you would do this:

[self doSomething:@"foo"];
XenElement