在“theMove *”类型的对象上找不到属性“move”

问题描述

我有 2 个课程,第一个在 Objective-c 中,第二个在 swift

在objective-c 类中,我想从swift 调用一些代码,但我收到此错误

Property 'move' not found on object of type 'theMove *'

在 swift 我有这个代码

@objc enum Move : NSInteger
{
   case one,two 
}
 
@objc public class theMove :NSObject
{    
    var move : Move
    @objc init(move : Move)
    {
        self.move = move
    }
}

在目标 -c

当我调用 fristTurn.move 时出现错误

@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