• 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
Re: key-value support for Objective-C "class" variables?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: key-value support for Objective-C "class" variables?


  • Subject: Re: key-value support for Objective-C "class" variables?
  • From: Keary Suska <email@hidden>
  • Date: Sat, 28 Jul 2007 10:59:30 -0600
  • Thread-topic: key-value support for Objective-C "class" variables?

on 7/28/07 9:20 AM, email@hidden purportedly said:

> So this may be a hopelessly naive question, but as I refactor a bunch
> of code to be all KV*, I realize that I have a few really handy class
> variables, say:
>
> @implementation Foo
>
> static CGFloat _widthTolerance_ = .5;
>
> + (CGFloat)widthTolerance {
> return _widthTolerance_;
> }
>
> + (void)setWidthTolerance:(CGFloat)v {
> _widthTolerance_ = v;
> }
>
>
> and I would really like to wire these up in IB with bindings for, say,
> a debugging panel inside my app.  Even if I'm wrapping them up inside
> of some sort of app controller as a reflected instance variable there,
> I'm then realizing that I'm not sure how I could notify interested
> parties in the fact that these values changed, short of sending out a
> notification.
>
> I'm assuming this topic has come up before, but googling hasn't
> helped...
>
> What's the conventional wisdom on this?

I would say that you should refactor out your "class" variable. I forget the
OOP rules on class variables but recall generally that it is a bad idea to
have instances change class data. I believe r/o access is OK, however, but
if you need r/w access you should move the data out to a more appropriate
implementation such as NSUserDefaults.

Best,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


_______________________________________________

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:
    • NSTimer: Target object missing when timer fires?
      • From: dream cat7 <email@hidden>
References: 
 >key-value support for Objective-C "class" variables? (From: Michael Johnson <email@hidden>)

  • Prev by Date: Re: Sending message to Objective-C object from C file
  • Next by Date: Posting Leopard Source Code
  • Previous by thread: key-value support for Objective-C "class" variables?
  • Next by thread: NSTimer: Target object missing when timer fires?
  • Index(es):
    • Date
    • Thread