问题描述
我有 2 个课程,第一个在 Objective-c 中,第二个在 swift
在objective-c 类中,我想从swift 调用一些代码,但我收到此错误
Property 'move' not found on object of type 'theMove *'
@objc enum Move : NSInteger
{
case one,two
}
@objc public class theMove :NSObject
{
var move : Move
@objc init(move : Move)
{
self.move = move
}
}
在目标 -c
@property (nonatomic) theMove * fristTurn;
fristTurn.move
解决方法
要么
@objc var move : Move
或
@objcMembers public class TheMove :NSObject
允许
@property (nonatomic) TheMove *firstTurn;
-(void)thing {
self.firstTurn = [[TheMove alloc] initWithMove:MoveTwo];
self.firstTurn.move = MoveOne;
}
Objective-C 推理得到严格执行。如果你不说它暴露给Objective-C,它就没有暴露。
也是风格点。首选大写的类名 TheMove
而不是 theMove
。