Élodie Petit
Élodie Petit

Reputation: 5914

Defining protocols without parameters

I am trying to define a protocol method without adding parameters but couldn't find the correct syntax.

Here is the definition (it has a syntax error)

- (void)cameraOverlayView:(CameraOverlayView *)cameraOverlay didTakePhoto;

I don't want to pass any values with the second parameter. My aim is only to signal that something happened to the delegate instance.

How should I write the definition?

Upvotes: 1

Views: 536

Answers (4)

Grady Player
Grady Player

Reputation: 14549

basically in objective c you can't have method name parts dangling after parameters... so:

illegal:

-(void)methodWith:(int)theInt forMyMom;

normal:

-(void)methodForMyMomWithInt:(int)theInt;

legal but strange

-(void)method:(int)theInt :(int)theOtherInt;

with the selector: @selector(method::)

Upvotes: 1

Marcel
Marcel

Reputation: 6579

Your the second part of the method is not formatted correctly:

- (void)cameraOverlayView:(CameraOverlayView *)cameraOverlay didTakePhoto;

Because of the space, it's expecting a parameter. Instead, work the didTakePhoto part into the method name, like:

- (void)cameraOverlayViewDidTakePhoto:(CameraOverlayView *)cameraOverlay;

Upvotes: 3

Nick Fishman
Nick Fishman

Reputation: 654

This is an issue of Objective-C convention. You could rewrite it as:

- (void)cameraOverlayView:(CameraOverlayView *)cameraOverlayViewDidTakePhoto;

Upvotes: -3

user529758
user529758

Reputation:

- (void)cameraOverlayViewDidTakePhoto:(CameraOverlayView *)cameraOverlay;

Upvotes: 1

Related Questions