문제

I'm declaring a lot of block types with typedef; is there any sort of naming convention for them?

도움이 되었습니까?

해결책 2

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.

다른 팁

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.

from Apple doc it's CamelCase with objective-C naming convention style (explicit/verbose)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top