【发布时间】:2011-12-05 14:49:52
【问题描述】:
我创建了一个类来在 1 行中处理我的 UILabel,而不是通过执行来处理 4-5 个...
+(UILabel*)BeautifyLabel:(UILabel *)label withText:(NSString *)message withFont:(NSString *)font andSize:(float)size andColor:(UIColor *)theColor{
label.backgroundColor = [UIColor clearColor];
label.textColor = theColor;
label.font = [UIFont fontWithName:font size:size];
label.text = message;
return label;
}
要称呼它,我愿意
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake....];
label = [CommonMethods BeautifyLabel:label withText:@"hi" withFont:@"Helvetica" andSize:13 andColor:[UIColor whiteColor]];
[self.view addSubview label];
[label release];
分析器可能不喜欢我将标签传递给我的 CommomMethods 类的部分,但由于我正在初始化并释放当前控制器中的标签,而 CommonMethods 类不做任何与内存相关的事情,这是安全吧?
另外,这会导致 Apple 拒绝我的应用吗?
谢谢
【问题讨论】:
-
苹果为什么要拒绝?
-
分析仪错误的文本是什么?它抱怨什么?
-
“调用者此时不拥有的对象的引用计数减少错误”,并在
[label release]行显示警告。
标签: iphone cocoa-touch memory-management