I have a subclasses PFObject - Conversation
. I need a custom setter for it's users
property.
So I changed @dynamic
to @synthesize
:
@synthesize users = _users;
And setup my setter as so:
-(void)setUsers:(NSArray *)users {
@synchronized (self)
{
_users = users;
self.numUsers = @(users.count);
[self setReadWriteACLsForUsers:users];
}
}
In my controller I set users
:
self.conversation.users = users;
NSLog(@"self.conversation = %@",self.conversation);
I set breakpoints on the users
setter and it seems to run through fine but in the log self.conversation
the users
property is nil
.
EDIT
I changed my setter/getter to this:
-(void)setUsers:(NSArray *)users {
@synchronized (self)
{
[super setObject:users forKey:[Conversation usersKey]];
self.numUsers = @(users.count);
[self setReadWriteACLsForUsers:users];
}
}
- (NSArray *)users
{
NSArray *ret = nil;
@synchronized (self)
{
ret = [super objectForKey:[Conversation usersKey]];
}
return ret;
}
If I set breakpoints on the getter, ret
has the correct values in them.
However, in this same conversation
instance, in XCode it's showing nil for the two instance variables that I am setting up custom setters/getters for:
https://i.stack.imgur.com/a1dAL.jpg - I need 10 reputation to post images inline
So basically my synthesized instance variables aren't corresponding to the object keys in the PFObject and I don't know how to reconcile this.