BluesZhang / gdata-objectivec-client

Automatically exported from code.google.com/p/gdata-objectivec-client
Other
0 stars 0 forks source link

-[GDataObject properties] is not fully KVO compliant #36

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Bind something to object.properties.key before userProperties_ has been 
initialized
2. Set property to some value (this will initialize the userProperties_ ivar)
3. Original binding is not updated when

Reason is this:

- (void)setProperty:(id)obj forKey:(NSString *)key {

  if (obj == nil) {
    // user passed in nil, so delete the property
    [userProperties_ removeObjectForKey:key];
  } else {
    // be sure the property dictionary exists
    if (userProperties_ == nil) {
      userProperties_ = [[NSMutableDictionary alloc] init];
    }
    [userProperties_ setObject:obj forKey:key];
  }
}

Using userProperties_ = [[NSMutableDictionary alloc] init]; does not trigger a 
bindings update.
Should use either willChangeValueForKey:@"properties" and 
didChangeValueForKey:@"properties" 
or [self setProperties:[NSMutableDictionary dictionary]];

Diff attached for the latter.

Original issue reported on code.google.com by matthew....@gtempaccount.com on 27 Aug 2009 at 10:18

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by gregrobbins on 27 Aug 2009 at 10:30

GoogleCodeExporter commented 9 years ago
Fixed on top-of-trunk.

http://code.google.com/p/gdata-objectivec-client/source/detail?r=323

Thanks for reporting this.

Original comment by gregrobbins on 29 Aug 2009 at 12:59