源文件的组织

问题描述

| 我的应用程序有两个类:
exampleAppDelegate
exampleController
。 我将
exampleController.h
导入
exampleAppDelegate.m
,并将
exampleAppDelegate.h
导入
exampleController.m
。 当我尝试在
exampleAppDelegate
类中使用
exampleController
类的插座或动作时,编译器返回以下错误:   使用未声明的标识符,未找到操作。 当我尝试使用
exampleController
中的
exampleAppDelegate
中的变量时,也会发生相同的问题。 我究竟做错了什么?     

解决方法

        如果要对多个文件使用相同的方法/选择器来处理事件(如UIControlEventTouchDown ...),请尝试使用
addTarget:action:forControlEvents:
方法添加它们,而不是通过IBAction(接口生成器)进行添加。 另外,我认为您在控制器中导入委托的方法不正确。