我做了一個使用委託模式的類,並將其放入靜態庫中。然後,我創建了一個演示應用程序來測試庫。演示只是有一個單一的視圖控制器,並在.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