Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Dynamic properties

#8

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

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

State: new
Milestone: none
Assigned to: nobody

Activity

  1. Deleted User
    Deleted User
    • 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

    February 5th, 2009 @ 05:39 PM

  2. Deleted User
    Deleted User
    • Tag changed from dynamic, kvc, property to dynamic, kvc, properties
    • Title changed from Dynamic property support to Dynamic properties

    February 5th, 2009 @ 05:44 PM

  3. Joshua Vickery
    Joshua Vickery

    Hi Josh (nice name!)

    This ticket was at odds with #9 add OR support with category on NSObject? 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?

    February 6th, 2009 @ 08:46 AM

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.