tags:

views:

136

answers:

1

What are the parenthesis doing in

[s addChild: [restartAction() node]];"

or what is that feature called? Thanks.

EDIT: I think the definition of restartAction() is

Class restartAction()
{
    NSString *r = transitions[sceneIdx];
    Class c = NSClassFromString(r);
    return c;
}

transitions[someint] returns a string. This string is used to return an object. I still don't understand why the parenthesis are needed though. I am expecting a colon after the parenthesis.

+5  A: 

restartAction looks like a plain C function that takes no arguments. It probably returns a pointer to an objective-c type.

Since restartAction returns an Objective-C Class type you can call class(+) functions on it. It's syntactically equivalent to when you call [NStype alloc];

If you want to experiment further you can get the Class variable for a type by calling [type class];

CynicismRising