1

我遇到了一个非常好的 API MBProgressHUD,但是当我阅读头文件MBProgressHUD.h中的文档时,我感到困惑,因为文档说这- (id)initWithWindow:(UIWindow *)window;是一个方便的构造函数

根据有关内存管理的 Apple 文档,便利构造函数不应以以下任何前缀为前缀:initalloccopy

谁能澄清我是否在这里遗漏了什么?

/*** 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;
4

1 回答 1

1

我相信问题出在评论上。便利构造函数返回自动释放的对象,但- (id)initWithWindow:(UIWindow *)window;事实并非如此。因此,构造函数的名称很好,但应该更新注释。

编辑:我总是觉得 MBProgressHUD 对我来说有点复杂,直到我在 github 上遇到了这个不错的替代品。

于 2011-09-27T11:28:38.480 回答