Xcode 7.3没有显示协议声明

时间:2016-04-22 06:19:03

标签: ios delegates protocols xcode7.3

我更新了Xcode 7.3。我观察到Xcode没有显示错误(警告)来实现委托方法,该方法在自定义协议声明中标记为 @required

项目正在成功构建,没有实现必需的委托方法。但是它会将"无法识别的选择器发送到实例"当我试图在运行时调用委托方法时出错,错误是显而易见的,但我很好奇为什么Xcode在编译时停止显示它。

在旧版本(例如Xcode 6.4)中给出。如果有人有任何想法,请分享。 提前谢谢。

这是我的协议声明, CustomViewController.h

#import <UIKit/UIKit.h>

@protocol MyCustomProtocol <NSObject>

- exampleDelegateMethod: (NSString*) test;

@end

@interface CustomViewController : UIViewController

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

@end

在另一个班级,我正在听我宣布的委托方法,

.h文件中的

#import "CustomViewController.h"
@interface AnotherViewController : UIViewController <MyCustomProtocol>
.m文件中的

        ((CustomViewController*)segue.destinationViewController).delegate = self;

1 个答案:

答案 0 :(得分:0)

我弄错了,而不是像代表那样听代表,

((CustomViewController*)segue.destinationViewController).delegate = self;

将其更改为,

CustomViewController* subscriptionViewController = segue.destinationViewController;
CustomViewController.delegate = self;

这解决了我的问题。 感谢所有花时间在这上面的人。