Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS delegate naming conventions - should, will, did

I am looking into naming conventions for iOS controls delegates. I am familiar with the should, will, did pattern for delegate methods. I can see this naming convention used extensively by the Apple APIs. My question is, are there any delegates supplied by apple that have should, will, did methods for a single action? e.g. for row selection:

shouldSelectRow
willSelectRow
didSelectRow

I have not found a delegate that defines all three. My feeling is that 'will' methods are often used in place of should, i.e. they can return a value in order to cancel the action.

Are there any counter-examples?

like image 298
ColinE Avatar asked Jul 25 '12 12:07

ColinE


1 Answers

Should methods always return a BOOL value, and tell you the current behavior of an object (But they are never called automatically). Will methods are delegate methods that get called when an event is about to happen, like

-(void)applicationWillResignActive...

and "did" methods are also delegate methods that get called after the event took place, like appplicationDidFinishLaunching...

like image 182
Jorge Aguirre Avatar answered Nov 10 '22 03:11

Jorge Aguirre