use*_*133 0 iphone delegates automatic-ref-counting ios6
在fastpdfkit中有这样的委托声明
@interface BookmarkViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {
//Delegate to get the current page and tell to show a certain page. It can also be used to
// get a list of bookmarks for the current document.
NSObject<BookmarkViewControllerDelegate> *delegate;
}
@property (nonatomic, assign) NSObject<BookmarkViewControllerDelegate> *delegate;
@synthesize delegate;
Run Code Online (Sandbox Code Playgroud)
因为我使用ARC所以委托的声明是这样的
@interface BookmarkViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {
id __unsafe_unretained <BookmarkViewControllerDelegate> delegate;
}
@property (unsafe_unretained) id <BookmarkViewControllerDelegate> delegate;
@synthesize delegate;
Run Code Online (Sandbox Code Playgroud)
这是正确的原因当即时调试我得到
currentPage NSUInteger 0
delegate objc_object * 0x00000000
Run Code Online (Sandbox Code Playgroud)
下面是一个模式.委托被正确地宣布为弱(一个对象但没有所有权转移或保留计数增加).
@protocol MyClassDelegate;
@interface MyClass : NSObject
@property(weak, nonatomic) id<MyClassDelegate>delegate;
@end
@protocol MyClassDelegate <NSObject>
- (void)myClass:(MyClass *)myClass didSomethingAtTime:(NSDate *)time;
- (CGSize)sizeofSomethingNeededByMyClass:(MyClass *)myClass;
// and so on
@end
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
516 次 |
最近记录: |