【发布时间】:2012-05-16 23:08:36
【问题描述】:
我是 iOS 5 的新手。从 Apple 的文档中,我知道 ARC 是什么以及“对象的所有者应该使用 strong 表示法。”读完“Hello World”后,我注意到一件奇怪的事情。(我的意思是这让我很困惑)
HelloWorldAppDelegate:
@interface HelloWorldAppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
HelloWorldViewController:
#import <UIKit/UIKit.h>
@interface HelloWorldViewController : UIViewController <UITextFieldDelegate>
@property (weak, nonatomic) IBOutlet UITextField *textField;
@property (weak, nonatomic) IBOutlet UILabel *label;
- (IBAction)changeGreeting:(id)sender;
@property (copy, nonatomic) NSString *userName;
@end
这里:
@property (weak, nonatomic) IBOutlet UITextField *textField;
@property (weak, nonatomic) IBOutlet UILabel *label;
UI 元素具有 weak 符号,并且没有一个文件具有对它们的 strong 引用。所以我很困惑what/who hold them?
【问题讨论】:
标签: iphone ios memory-management ios5 automatic-ref-counting