gpt4 book ai didi

objective-c - 在类型错误的对象上找不到属性,但属性存在

转载 作者:行者123 更新时间:2023-12-03 17:10:54 25 4
gpt4 key购买 nike

所以我试图访问 SerialPortController 中的属性 isPortClosed(BOOL) ,它给了我一个错误,我对 Objective-C 有点陌生。我觉得这应该可行,因为我已经通过 *port 引用了该类。这是project.的链接

错误消息:~/GroundStation/GroundStation/ViewController.m:16:22:在“SerialPortController *”类型的对象上找不到属性“isPortClosed”

        #import <Cocoa/Cocoa.h>
#import "SceneView.h"
#import "SerialPortController.h"

@interface ViewController : NSViewController
@property (strong) IBOutlet SerialPortController *port;
@property (weak) IBOutlet SceneView *accelSceneView;



@end
#import "ViewController.h"

@implementation ViewController

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
while(!self.port.isPortClosed) {

}
}

- (void)setRepresentedObject:(id)representedObject {
[super setRepresentedObject:representedObject];

// Update the view, if already loaded.
}

@end

SerialPortController.h 类

#import <Foundation/Foundation.h>
#import <ORSSerial/ORSSerial.h>

@interface SerialPortController : NSObject <ORSSerialPortDelegate>
@property (nonatomic, strong) ORSSerialPort *serial;
@property (nonatomic, strong) ORSSerialPortManager *serialPortManager;
@property (nonatomic) NSInteger xAngle;
@property (nonatomic) NSInteger yAngle;
@property (nonatomic) NSInteger zAngle;
@property (nonatomic) NSString *stringBuffer;
@property (nonatomic) BOOL isPortClosed;
@end

最佳答案

从下载的项目中,我看到您有两个 SerialPortController 类定义(一个位于根目录,一个位于/GroundStation/中),而后者没有任何公共(public)属性。您的项目中应该只有一个链接的 SerialPortController 类定义(具有公共(public)属性的类定义)。

关于objective-c - 在类型错误的对象上找不到属性,但属性存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29948686/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com