1

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 with 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;
Mogsdad
  • 44,709
  • 21
  • 151
  • 275
mrd3650
  • 1,371
  • 3
  • 16
  • 24

1 Answers1

1

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.

mja
  • 5,056
  • 1
  • 29
  • 40
  • Thanks @mja for the clarification and also for the alternative progressHUD link. I gave it a look and yes it seems simple enough. However I want to point out that MBProgressHUD has one very good feature; with just one line you can display the HUD while running a @selector() and stopping as it finishes. – mrd3650 Sep 28 '11 at 07:06