zyxel
zyxel

Reputation: 1094

Objective C methods naming conventions

What name is better for the "delete" method that deletes document in database with given documentID?

1) -(void) deleteDocumentWithID:(NSString *) documentID error:(NSError **)error;

or

2) -(void) deleteDocumentByID:(NSString *) documentID error:(NSError **)error;

Upvotes: 1

Views: 727

Answers (2)

Parag Bafna
Parag Bafna

Reputation: 22930

Have a look at Programming with Objective-C

  • Method names do not have a prefix
  • Method should start with a lowercase letter
  • camel case is used for multiple words
  • If a method takes one or more arguments, the name of the method should indicate each parameter
  • Error should be the last parameter to the method

enter image description here

By and with depends on you

 -(void) deleteDocumentWithID:(NSString *) documentID error:(NSError **)error;

 -(void) deleteDocumentByID:(NSString *) documentID error:(NSError **)error;

Upvotes: 2

sbarow
sbarow

Reputation: 2819

Your naming conventions are completely up to you, as mentioned in the apple doc try and be as descriptive as possible with your method names so any third party looking at your code (header file) will be able to get an idea quickly on what the method does. From the code you posted you are on the right track.

Have a look at this document.

Apple Conventions

Upvotes: 2

Related Questions