已在头文件中声明了一个协议,但实现文件说它无法看到该委托。为什么呢?
Xcode编译器消息在实现文件中被注释掉。
提前致谢。
AddItemViewController.h
#import <UIKit/UIKit.h>
@class AddItemViewController;
@class ChecklistItem;
@protocol AddItemViewControllerDelegate <NSObject>
- (void)addItemViewControllerDidCancel:(AddItemViewController *)controller;
- (void)addItemViewController:(AddItemViewController *)controller didFinishAddingItem:(ChecklistItem *)item;
@property (nonatomic, weak) id <AddItemViewControllerDelegate> delegate;
@end
@interface AddItemViewController : UITableViewController <UITextFieldDelegate>
@property (weak, nonatomic) IBOutlet UITextField *textField;
@property (weak, nonatomic) IBOutlet UIBarButtonItem *doneBarButton;
- (IBAction)cancel;
- (IBAction)done;
@end
AddItemViewController.m
- (IBAction)cancel
{
[self.delegate addItemViewControllerDidCancel:self]; /* Semantic issue: Property 'delegate' not found on object of type "AddItemViewController" */
}
- (IBAction)done
{
ChecklistItem *item = [[ChecklistItem alloc] init];
item.text = self.textField.text;
item.checked = NO;
[self.delegate AddItemViewController:self didFinishAddingItem:item]; /* Semantic issue: Property 'delegate' not found on object of type "AddItemViewController" */
}
答案 0 :(得分:3)