-[NSManagedObject setValuesForKeysWithDictionary:] and C++ attributes
-[NSManagedObject setValuesForKeysWithDictionary:] and C++ attributes
- Subject: -[NSManagedObject setValuesForKeysWithDictionary:] and C++ attributes
- From: Rick Mann <email@hidden>
- Date: Thu, 01 Nov 2012 19:44:16 -0700
I'm trying to copy NSManagedObjects using -dictionaryWithValuesForKeys and -setValuesForKeysWithDictionary:. Some of my attributes are C++ objects (simple ones). For example:
class
Rect : public CGRect
{
};
@interface
MyObj : NSManagedObject
@property (nonatomic, assign) Rect bounds;
@end
When I get the dictionary of values from the source object, I get something reasonable:
(lldb) po values
(NSDictionary *) $0 = 0x0000000400770ae0 {
bounds = "<00000000 000030c0 00000000 000038c0 00000000 00004040 00000000 00004640>";
}
But when I try to set the values in the target object, my setBounds: method
- (void)
setBounds: (Graphics::Rect) inVal
{
NSString* v = NSStringFromRect(NSRectFromCGRect(inVal));
[self willChangeValueForKey:@"bounds"];
self.shadowBounds = v;
[self didChangeValueForKey:@"bounds"];
}
gets called with
inVal = (Rect &) 0x0000000000000000
> CGRect (CGRect)
Showing in the debugger. That is, the type of inVal is a Rect reference (Rect&).
Something's clearly not right. Can I even do this?
Thanks,
--
Rick
_______________________________________________
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