gpt4 book ai didi

ios - 实现文件看不到协议(protocol)委托(delegate)

转载 作者:行者123 更新时间:2023-11-28 19:59:21 26 4
gpt4 key购买 nike

已经在头文件中声明了一个协议(protocol),但是实现文件说它看不到委托(delegate)。为什么?

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" */

}

最佳答案

啊..这是打错了吗?委托(delegate)属性在委托(delegate)协议(protocol)中定义。当然VC类是看不到的;)

关于ios - 实现文件看不到协议(protocol)委托(delegate),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24874782/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com