Reputation: 13277
I'm declaring a lot of block types with typedef; is there any sort of naming convention for them?
Upvotes: 0
Views: 749
Reputation: 2171
After doing a bunch of research, it seems that Apple doesn't typedef their blocks, and prefers to just name the parameters explicitly where they are used. Their Cocoa style guide also makes no mention of blocks being typedef'd.
For example, look at this method in NSURLSession.h from the NSURLSessionTaskDelegate
:
- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task
willPerformHTTPRedirection:(NSHTTPURLResponse *)response
newRequest:(NSURLRequest *)request
completionHandler:(void (^)(NSURLRequest * _Nullable))completionHandler;
Note that the completionHandler doesn't receive a typedef.
In my opinion, it only makes sense to typedef a block if the definition is immediately reusable, and is generic enough to be used in multiple places.
Upvotes: 1
Reputation: 926
from Apple doc it's CamelCase with objective-C naming convention style (explicit/verbose)
Upvotes: 0
Reputation: 10329
See here in Apple's documentation, Enumerated constants and Naming Properties and Data Types
I can't really find anything in Apple's documenation, but I did fins one from AppCelerator.
Upvotes: 0