No Setter method for assignment to property - cocoa application
Asked Answered
A

1

10

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
Anchie answered 15/2, 2015 at 17:22 Comment(1)
May I suggest you find a modern tutorial. The use of @synthesize hasn't been needed for a few years now.Dambro
S
27

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.

Sadiras answered 15/2, 2015 at 17:30 Comment(2)
Ah okay, thanks for the tip. Code worked as well, thanks alot.Anchie
Glad to hear you got it working mate. If it did answered your question, I would appreciate if you could mark it as accepted answer.Sadiras

© 2022 - 2024 — McMap. All rights reserved.