#8 new
Joshua Vickery

Dynamic properties

Reported by Joshua Vickery | December 30th, 2008 @ 08:24 AM

we could add support for dynamic properties in addition to the synthesized ones we support now

this would save typing the variable declaration and the release call

to do this, we would need to keep an attribute hash in the superclass and implement the KVC valueForUndefinedKey: methods

Comments and changes to this ticket

  • Deleted User

    Deleted User February 5th, 2009 @ 05:39 PM

    • Tag set to dynamic, kvc, property
    • Title changed from “add dynamic property support?” to “Dynamic property support”

    Hi,

    I already have code for this from a project I started before ObjectiveResource came about. It automatically infers the properties as they are unserialized and stores them in a hash in the superclass. It also uses KVC to retrieve the properties (as suggested).

    I would be more than happy to merge this feature if you would like to see it included in ObjectiveResource.

    Josh

  • Deleted User

    Deleted User February 5th, 2009 @ 05:44 PM

    • Tag changed from dynamic, kvc, property to dynamic, kvc, properties
    • Title changed from “Dynamic property support” to “Dynamic properties”
  • Joshua Vickery

    Joshua Vickery February 6th, 2009 @ 08:46 AM

    Hi Josh (nice name!)

    This ticket was at odds with #9 which moved ObjectiveResource from using a superclass, to implementing all the functionality as a category on NSObject. The downside of using a category is that there is no iVar support and, alas, Objective-C doesn't do "class" variables.

    The only way that I now see to support this ticket would be to use a global or static map of objects to store all the attribute hashes, and I'm not to keen on that approach.

    Do you have any other thoughts?

    As a side note, the reason I wanted dynamic properties is because I almost always use iVar backed nonatomic,retain properties, which means that I need to repeat myself 4 times every time I want a new one.

    @interface Foo {
      NSString *propertyName;
    }
    @property (nonatomic,retain) NSString *propertyName;
    @end
    
    @implementation Foo
    @synthesize propertyName;
    -(void) dealloc {
      [propertyName release];
      [super dealloc];
    }
    @end
    
    

    Dynamic properties mean that I can cut that repetition down to 2, but my ideal solution would be not having to repeat anything. Does that mesh with what your logic?

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Port of Rails' ActiveResource framework to the iPhone.

Shared Ticket Bins

People watching this ticket

Referenced by

Pages