nibeck
nibeck

Reputation: 669

Multiple @implementation block in single file

I have been looking at some sample code from Apple, specifically the AVCam project that uses the AVFoundation framework.

It the main view controller file, the developer has multiple @implementation sections:

@implementation AVCamViewController
@implementation AVCamViewController (InternalMethods)
@implementation AVCamViewController (AVCamCaptureManagerDelegate)

They also have corresponding @interface sections for each.

All of these are in the single AVCamViewController.m file. I've never seen this done before and was wondering about the rationale behind it.

Is this just a personal style?

Does it provide any inherent advantages?

Upvotes: 2

Views: 462

Answers (1)

cscott530
cscott530

Reputation: 1708

They are called categories. Here is a good explanation: https://stackoverflow.com/a/864877/865967

I'm sure somebody else can provide a more specific reason, but I think when people use this pattern within the same .h/.m files, it's just for readability and separation.

Upvotes: 4

Related Questions