• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Translating KVO-ed property to Swift
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Translating KVO-ed property to Swift


  • Subject: Translating KVO-ed property to Swift
  • From: Rick Mann <email@hidden>
  • Date: Mon, 17 Apr 2017 01:24:14 -0700

I have a number of properties in Objective-C written like this, short-circuiting notifications when the value doesn't change:

-------------
@synthesize version = mVersion

- (void)
setVersion: (NSString *) inVersion
{
    if (inVersion == nil && mVersion == nil)
    {
        return;
    }
    if ([inVersion isEqualToString: mVersion])
    {
        return;
    }

    [self willChangeValueForKey: @"version"];
    mVersion = inVersion;
    [self didChangeValueForKey: @"version"];
}
-------------

Now I want to translate this method into Swift. Thing is, AFAIK you can't name the ivar created for a property. Is there a way to translate this to swift?

TIA,

--
Rick Mann
email@hidden


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Translating KVO-ed property to Swift
      • From: Quincey Morris <email@hidden>
    • Re: Translating KVO-ed property to Swift
      • From: Jean-Daniel <email@hidden>
  • Prev by Date: Re: Help Indexing
  • Next by Date: Re: Translating KVO-ed property to Swift
  • Previous by thread: Programming for the MacBook Pro Touch Bar
  • Next by thread: Re: Translating KVO-ed property to Swift
  • Index(es):
    • Date
    • Thread