Good afternoon, I study xcode It is required to add for visual components. theme attribute. I wrote the following class, but I don’t understand how to create getter and setter correctly for working with an instance variable of an object. As I understand it, the _theme variable that I declared is static. Thank you @ "Max Mikheyenko" for information: Restrictions on creating categories: Impossible to create variables! The question remains: how to add setter and getter theme to work with User defined run time attributes in Xcode?

NSView.h

#import <Cocoa/Cocoa.h> @interface NSView (FrameworkAdditions) @property (nonatomic, assign) IBInspectable NSString *theme; - (void) changeTheme; @end 

NSView.m

 #import "NSView.h" @implementation NSView(FrameworkAdditions) NSString * _theme; -(void) setTheme:(NSString *)theme { _theme = theme; [self changeTheme]; } -(NSString *) theme{ return _theme; } - (void) changeTheme { NSLog(@"Get %@ %@", [self theme], self.view); } @end 
  • in .m you don’t need to do anything at all. @property should be enough - Max Mikheyenko
  • Then the application swears: Failed to set (theme) user defined inspected property on (NSView): [<NSView 0x6000001214a0> setValue: forUndefinedKey:]: this is not a key value. The point is probably in the declaration of NSView (FrameworkAdditions), which, as I understand it, extends the standard implementation of NSView - Denis
  • and why you have nsstring is assigned assign - Max Mikheyenko
  • @ Max, what do you suggest? I tried various options ... - Denis
  • well, either strong or nothing, because strong is still default - Max Mikheyenko

0