0

I've written one ages ago but I can't find it now.

How do you create a creator function for a class that uses the same syntax as [NSArray array];?

i.e.

+ (id)object;

Instead of...

- (id)initWithBlah...

Thanks

1 Answer 1

3

It's called a constructor and a typical implementation may be

+ (NSArray *)array
{
    return [[[self alloc] init] autorelease];
}
Sign up to request clarification or add additional context in comments.

2 Comments

Gah, yeah, I knew it wasn't a creator but I couldn't remember the name. Thanks! :D
I think it's called a "convenience constructor" or something

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.