What is the best practice for naming an Objective-C selector that doesn’t take parameters but can return an Error?
Example (a method that gets soundtrack data from the web):
- (NSData*) soundtrackData:????? error:(NSError**)error;
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Apple uses one of two styles in the Cocoa frameworks:
e.g.
-[NSManagedObjectContext save:]e.g.
-[NSURL checkResourceIsReachableAndReturnError:It would seem that Apple is favouring the second style for new APIs these days, but either is acceptable. I like the conciseness of the first style, but the second does have a nice advantage that you can search for
error:to find all methods in your code with error-handling.