没有用于赋值给属性的Setter方法 - 可可应用程序

Ste*_*ies 2 cocoa objective-c nstextfieldcell

我对objective-c相当新,刚遇到一个我以前没见过的错误.我正在尝试将文本字段单元格设置为"可选",但我得到错误"没有Setter方法'setIsSelectable'用于赋值给属性."

这是.h和.m文件.谢谢.

DataPanel.h
#import <Cocoa/Cocoa.h>

@interface DataPanel : NSPanel
@property (weak) IBOutlet NSTextFieldCell *textField;

@end



DataPanel.m
#import "DataPanel.h"

@implementation DataPanel
@synthesize textField = _textField;

- (void) awakeFromNib{

_textField.stringValue = @"1.1 Performance standards The overall objective of       the performance standards in Section 1.1 is to provide acoustic conditions in schools that (a) facilitate clear communication of speech between teacher and student, and between students, and (b) do not interfere with study activities.";
_textField.isSelectable = YES;
}

@end
Run Code Online (Sandbox Code Playgroud)

AMI*_*289 14

在Objective-C中,BOOL以'is'开头的属性通常只是属性的getter,而不是属性本身.
这是一个惯例.

只是为了一般知识,您可以通过以下方式声明属性来自己完成:
@property (nonatomic, getter=isAvaiable) BOOL available;

所以试图设置上面的内容,虽然使用isAvailable不起作用,因为它是getter方法,你不能设置一个getter.

至于您的问题,
请尝试将代码更改_textField.isSelectable = YES;为以下任一项,它应该可以正常工作.
_textField.selectable = YES;
[_textField setSelectable:YES];

祝你好运.