• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Where in the MVC should my code go?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Where in the MVC should my code go?


  • Subject: Re: Where in the MVC should my code go?
  • From: Jean-Henri Duteau <email@hidden>
  • Date: Sun, 28 Feb 2010 20:22:27 -0800

What you're essentially suggesting is putting this code in the model and I don't think it goes there.  The various strings that get displayed on the view are for the purposes of the view only.  They don't have any use in the model.

I explored using Transformer's some more because, after I wrote my last response, I thought that it really is a Transformer that I need.  Unfortunately, I can't see any way to get access to the Transformer instance that is attached to a binding.  It would work out if I did.  In my View Controller's awakeFromNib:, I could iterate through all of the Transformer instances and tell them what transform to do.

In the end, I may just bite the bullet and create the 20 Transfomer objects.  It will just be yucky code.

Jean

On 2010-02-28, at 1:49 PM, Chris Hanson wrote:

> On Feb 27, 2010, at 11:34 PM, Jean-Henri Duteau wrote:
>
>> BTW, I've already considered a Transformer.  The problem with that is one of code bloat - I have multiple fields on the view that are derived from this one attribute.  I haven't figured out a way at design time in IB to make one transformer handle the different transformations.
>
> Maybe instead of being a single attribute (by which you mean it’s a string, URL or some such value class), your model object should have a relationship to another model object that you can manipulate more directly.
>
> Then that other model object can have a -stringValue or -URLValue (or whatever) method to “format” itself as the appropriate value class when you really it in that form.  (And perhaps a setter or initializer from that value type as well.)
>
> For example, if I were writing a file-transfer application, I wouldn’t directly use NSURL to represent the host, port, directory, protocol, etc.  I’d use some other (fully mutable) model object that can return itself as a URL.  My UI would be bound to that other model object, and only when I need a full URL would I ask that other model object for an equivalent NSURL instance.
>
>  — Chris
>

_______________________________________________

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

  • Follow-Ups:
    • Re: Where in the MVC should my code go?
      • From: Quincey Morris <email@hidden>
References: 
 >Where in the MVC should my code go? (From: Jean-Henri Duteau <email@hidden>)
 >Re: Where in the MVC should my code go? (From: Matthew Lindfield Seager <email@hidden>)
 >Re: Where in the MVC should my code go? (From: Jean-Henri Duteau <email@hidden>)
 >Re: Where in the MVC should my code go? (From: Chris Hanson <email@hidden>)

  • Prev by Date: Re: Carbon is C++?
  • Next by Date: Re: Carbon is C++?
  • Previous by thread: Re: Where in the MVC should my code go?
  • Next by thread: Re: Where in the MVC should my code go?
  • Index(es):
    • Date
    • Thread