KVO - receptionist design pattern
KVO - receptionist design pattern
- Subject: KVO - receptionist design pattern
- From: Kevin Meaney <email@hidden>
- Date: Sun, 01 Dec 2013 15:26:39 +0000
Hi all,
In Xcode 5 and on Mavericks only. I'm only looking forward with this project.
This is fairly simple. I hope it comes across that way.
In the XIB editor, in the bindings editor I'm setting the value binding of a text field to a property of my application delegate. This property is mostly changed on a queue that is not the main queue (gcd queues, not NSOperation queues). Everything works as I would like but I'm concerned that it is only working out of luck rather than proper design.
Has something changed in Mavericks so that doing this is no longer a problem, or do I need to fix. Because this is a simple case (I know when I'm not on the main thread) I can easily fix with just wrapping the modification of the property like so:
__weak AppDelegate *weakSelf = self;
dispatch_async(dispatch_get_main_queue(), ^
{
AppDelegate *strongSelf = weakSelf;
if (strongSelf)
strongSelf.isAgentRunning = isRunning ? @"Yes" : @"No";
});
But of course this is fine in my simple case, and since this is all I need I'll go with this. But for a more robust case where you don't have to worry about on what thread/queue the property was modified on I'm assuming the receptionist design pattern is the way to go. I've only just been reading about the receptionist design for the first time today. I'm amazed I missed it.
But what I suppose I'm asking is, are others using the receptionist design pattern, is it the way to go for a robust solution to this problem? What has been your experience?
Kevin
_______________________________________________
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