【问题标题】:Property 'move' not found on object of type 'theMove *'在“theMove *”类型的对象上找不到属性“move”
【发布时间】:2021-06-30 01:48:09
【问题描述】:

我有 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

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

@property (nonatomic) theMove * fristTurn;

fristTurn.move 

你能帮我解决这个错误吗

【问题讨论】:

    标签: swift objective-c iso


    【解决方案1】:

    要么

    @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

    【讨论】:

      猜你喜欢
      • 2014-04-27
      • 2012-03-04
      • 1970-01-01
      • 2023-03-22
      • 2019-06-25
      • 2012-07-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多