我試圖在Objective-C代碼中使用Swift類。Object-C中的Swift代碼:'ClassName'中沒有可見的@interface聲明選擇器'alloc'
ThisClass *thisClass = [[ThisClass alloc] init];
然而,試圖分配和初始化類時,我得到這個錯誤:
No visible @interface for 'ThisClass' declares the selector 'alloc'
類被聲明爲這樣的斯威夫特文件:
@objc class ThisClass : NSObject {
類繼承來自NSObject,所以我不知道它的問題是什麼。
這裏是我的我的項目名 - swift.h內部類:
SWIFT_CLASS("_TtC21ProductName16ClassName")
@interface ThisClass : NSObject
@property (nonatomic, copy) NSArray<Presentation *> * __nonnull presentations;
@property (nonatomic, copy) NSArray<Presentation *> * __nonnull userPresentations;
@property (nonatomic, strong) NSCache * __nonnull imageCache;
- (UIImage * __nullable)imageForPresentationSlideWithPresentation:(Presentation * __nonnull)presentation slideNumber:(NSInteger)slideNumber;
- (UIImage * __nullable)thumbnailForPresentationSlideWithPresentation:(Presentation * __nonnull)presentation slideNumber:(NSInteger)slideNumber;
- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
@end
謝謝,我改變了它 - 試圖保持真正的源代碼私人 – etayluz
這是有道理的,但我有這個在頂部:#import「ProjectName-swift.h」 – etayluz
讓我們[在聊天繼續討論]( http://chat.stackoverflow.com/rooms/93426/discussion-between-etayluz-and-matt)。 – etayluz