2013-07-11 43 views
1

我想從子類發送數據到父類。實現我的自定義授權後,我收到此錯誤:從子類到父類的自定義委派(subview-superview)

Cannot find protocol declaration for 'SLBPostViewControllerDelegate' 

這裏是我的代碼:

child.h

@protocol SLBPostViewControllerDelegate <NSObject> 

- (void)dataToBeUploaded:(PFFile *)data; 

@end 

@interface 

@property (weak, nonatomic) id <SLBPostViewControllerDelegate> delegate; 

@end 

child.m

[self.delegate dataToBeUploaded:image]; 

parent.h

@interface SLBWallViewController : UIViewController <SLBPostViewControllerDelegate> 

parent.m

- (void)dataToBeUploaded:(PFFile *)data{ 
    NSLog(@"%@", data); 
} 

哪裏是我的錯誤?我該如何解決它?

回答

1

parent.h需要#import child.h以瞭解協議聲明。

如果您正在導入它並仍然收到錯誤,則可能存在循環導入。在這種情況下,向前申報parent.h以上的協議@interface就像

@protocol SLBPostViewControllerDelegate; 

@interface SLBWallViewController : UIViewController <SLBPostViewControllerDelegate> 
... 
@end 
相關問題