无法为 NSObject 或 WKInterfaceController 的属性指定 setter 'setTitle:'

Cannot specify setter 'setTitle:' for properties of NSObject or WKInterfaceController

我正在尝试设置 WKInterfaceTable。我跟着苹果文档。我的标签没有收到文本,我在控制台中收到此错误消息:

Cannot specify setter 'setTitle:' for properties of NSObject or WKInterfaceController

我该如何解决这个问题? Objective-C 请。这是我的代码:

.h

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

@interface MainRowType : NSObject

@property (strong, nonatomic) IBOutlet WKInterfaceImage *image;
@property (strong, nonatomic) IBOutlet WKInterfaceLabel *title;

@end

.m

#import "MainRowType.h"

@implementation MainRowType


@end

.h

#import <WatchKit/WatchKit.h>
#import <Foundation/Foundation.h>
#import "MainRowType.h"

@interface WatchTableController : WKInterfaceController


@property (strong, nonatomic) IBOutlet WKInterfaceTable *tableView;
@property (strong, nonatomic) NSMutableArray *titleArray;


@end

.m

我调用这个方法

- (void)configureTableWithData:(NSMutableArray*)dataObjects {

    [self.tableView setNumberOfRows:[dataObjects count] withRowType:@"mainRowType"];

    for (NSInteger i = 0; i < self.tableView.numberOfRows; i++) {
        MainRowType* theRow = [self.tableView rowControllerAtIndex:i];
        NSString *titleString = [dataObjects objectAtIndex:i];

        [theRow.title setText:titleString];

    }
}

谢谢

你的title属性就是问题所在。你不能在 类 中命名 属性 "title"。更改 属性 名称,您应该一切就绪。