Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No Setter method for assignment to property - cocoa application

I'm fairly new to objective-c and have just encountered an error i've not seen before. I'm trying to set a Text Field cell as 'selectable', but i get the error "No Setter method 'setIsSelectable' for assignment to property."

Here are the .h and .m files. Thanks.

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
like image 297
Steffan Davies Avatar asked Nov 29 '22 23:11

Steffan Davies


1 Answers

In Objective-C, BOOL properties which start with 'is' are usually the getter of the property only, and not the property itself.
Its a convention.

Just for general knowledge, you can do so yourself by declaring properties in the following manner:
@property (nonatomic, getter=isAvaiable) BOOL available;

So trying to set the above, while using isAvailable will not work, since it is the getter method, and you can't set a getter.

As for your question,
Try changing your code from _textField.isSelectable = YES; to either of the below, and it should work.
_textField.selectable = YES;
[_textField setSelectable:YES];

Good luck mate.

like image 94
AMI289 Avatar answered Dec 06 '22 02:12

AMI289