SachinKS 2013-08-19 09:20 采纳率: 0%
浏览 2221
已采纳

使用ARC声明delegates

在fastpdfkit中声明delegates:

@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;

使用了ARC的声明:

@interface BookmarkViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {

 id __unsafe_unretained <BookmarkViewControllerDelegate> delegate;
 }

@property (unsafe_unretained) id <BookmarkViewControllerDelegate> delegate;

 @synthesize delegate;

在调试时报的结果:

currentPage    NSUInteger  0
delegate    objc_object *   0x00000000
  • 写回答

1条回答

  • loFataMer 2013-08-19 09:29
    关注

    这有一个模式,delegates声明为weak。

    @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
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 关于#python#的问题:自动化测试