LoginSignup
0
0

More than 5 years have passed since last update.

ObjC to Swift : Doing some work inside setter

Last updated at Posted at 2015-05-04

Objective-C

@property (assign) BOOL selected;

- (void) setSelected: (BOOL) aBool
{
    _selected = aBool;

    self.color = _selected ? [NSColor redColor] : [NSColor blackColor];
}

Swift

var selected: Bool = false
{
    didSet
    {
        self.color = selected ? NSColor.redColor() : NSColor.blackColor()
    }
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0