MBProgressHUD naming convention clarification
I came across a very nice API MBProgressHUD, however when I was reading the documentation in the header MBProgressHUD.h I got confused since the doc says that - (id)initWithWindow:(UIWindow *)window;
is a convenience constructor.
According to Apple docs regarding memory management, convenience constructors should not be prefixed with any of the following: init, alloc, copy.
Can anyone clarifies whether I'm missing something here?
/*** A convenience constructor that initializes the HUD wi开发者_JAVA技巧th the window's bounds.
* Calls the designated constructor with
* window.bounds as the parameter.
* @param window The window instance that will provide the bounds for the HUD.
* Should probably be the same instance as
* the HUD's superview (i.e., the window that the HUD will be added to).
*/
- (id)initWithWindow:(UIWindow *)window;
I believe the problem is with the comment. The convenience constructors return autoreleased objects, but this - (id)initWithWindow:(UIWindow *)window;
does not. Thus, the name of the constructor is fine, but the comment should be updated.
edit: I always found the MBProgressHUD a bit complicated to my taste until i came across this nice replacement on github.
精彩评论