temporary_user_name
temporary_user_name

Reputation: 37058

What does this syntax mean relating to interface declaration?

This is from the ViewController.m file in a starter project from a tutorial for a game.

@interface ViewController()

//irrelevant stuff omitted

@end

It's the ViewController() bit that confuses me. I understand the different between public and private interfaces, but I haven't used a private interface til now in Objective-C. I'm used to seeing something like this instead, for the public interface:

@interface ViewController : UIViewController

So why now is it just the first one, and with parentheses, with no inheritance notation?

Upvotes: 0

Views: 54

Answers (1)

Ken Thomases
Ken Thomases

Reputation: 90551

That's a class extension. It allows for declaring additional interface, usually private because it's in an implementation (.m) file. It's similar to a category, except that the compiler will require you to supply the implementation for any interface declared within it. (A category can declare an interface even if nothing provides any implementation.)

Upvotes: 3

Related Questions