出现这种错误可能因为类名跟函数名冲突,特别是在出现代理的时候,例如
#import <UIKit/UIKit.h>
@class UCSPasswordView;
@protocol UCSPasswordViewDelegate <NSObject>
#pragma mark - 输入完回掉
- (void)UCSPasswordView:(UCSPasswordView *)passwordView withPassword:(id)password;
#pragma mark-- 输入不符合格式的
@end
@interface UCSPasswordView : UIView
@property (nonatomic,weak) id<UCSPasswordViewDelegate> delegate;
@end
用swift遵守上面OC写的协议时肯定在在swift处报use of undeclared type ***错。因为Delegate里面的方法UCSPasswordView跟类名UCSPasswordView冲突了。以下这句话引自stackoverflow的回答:(http://stackoverflow.com/questions/24627598/use-of-undeclared-type-in-swift-project)
Your delegate function name is VKConnector
and
you also have a class named VKConnector
.
That's your conflict. In Objective C your delegate method is VKConnector:withBool:
but
in Swift it's simply VKConnector
and
withBool is not a part of the name.