Re: Binding a unique-selection checkbox in a table view?
Re: Binding a unique-selection checkbox in a table view?
- Subject: Re: Binding a unique-selection checkbox in a table view?
- From: Jerry Krinock <email@hidden>
- Date: Sun, 23 Nov 2014 16:22:16 -0500
The code posted by Lee Ann Rucker is good. It implements the ‘activeJob’ in the data model as I recommended. Your “data model” can include whatever classes you need to model your data, not just Job objects. Lee Ann is proposing that your data model also contain a single instance of a DataModel (rename as you like) class, which keeps track of the ‘activeJob’. You will probably find other nifty uses for it in the future.
It’s a subtle difference and a subtle change. To correct the smell, you just factor the activeJob property out of your AppDelegate, which is part of your controller layer, and move it into this new DataModel (or whatever) single object instance. This new class is part of your data model, because you say it is, and because it does not do any controller functions, as your app delegate certainly does.
It does require a little code to (1) initially create your single DataModel object and (2) for robustness, check for and re-create one if it ever disappears. For a document-based application, you would typically do (1) in -[NSDocument initWithType:error:], because this method runs only for new documents, and do (2) in -readFromData/URL/FileWrapper:ofType:error:.
_______________________________________________
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