我做了一个使用委托模式的类,并将其放入静态库中。然后,我创建了一个演示应用程序来测试库。演示只是有一个单一的视图控制器,并在.h文件中,我有这样的:代表静态库中Xcode不工作
@interface ViewController : UIViewController <AuthenticationDelegate>
@property (nonatomic, retain) IBOutlet UITextField *usernameTextField;
@property (nonatomic, retain) IBOutlet UITextField *passwordTextField;
@end
当我编译,我得到该文件的第一行一个错误,指出正确的:
Cannot find protocol declaration for 'AuthenticationDelegate'.
但是,对于同一视图控制器.m文件,我有:
#import "Authentication.h"
#import "ViewController.h"
文件“Authentication.h”是我的静态库的唯一的头文件,它也宣布委托类:
@class AuthenticationProvider;
@protocol AuthenticationDelegate <NSObject>
@optional
- (void)provider:(AuthenticationProvider *)provider didReplyWithResponse:(AuthenticationProviderResponse)response;
@end
我哪里错了?
更新:
如果我把#import "Authentication.h
在ViewController.h,我得到这个:
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_AuthenticationProvider", referenced from:
objc-class-ref in ViewController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我得到的,当我从ViewController.m删除#import "Authentication.h
也。
如果您引用AuthenticationDelegate在视图控制器头文件试试
#import "Authentication.h"
,你需要把进口存在。 – jtomschroeder 2012-07-12 18:13:57@ j.tom.schroeder我试过,但我得到了错误,我更新我的问题。 – woz 2012-07-12 18:18:29