Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7701857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:05:39+00:00 2026-05-31T23:05:39+00:00

I’m working on an iPhone application and trying to conform to MVC as much

  • 0

I’m working on an iPhone application and trying to conform to MVC as much as possible (I’m still learning). I have an Unsigned integer in my data model that represents a number of seconds. I want this to be displayed in a view in the format ’00:00′(minutes:seconds). My question is, where should this formatting take place?
Is it the model object’s responsibility to be able to provide it in this format?
Does the controller format this after taking it from the model but before passing it to the view?
Or does the view handle the formatting?

Thank you for any help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T23:05:40+00:00Added an answer on May 31, 2026 at 11:05 pm

    If this formatting is only used in one place, the best solution is to put formatting into the view, and this approach often works quite well. If you do not have a custom view, however, then it is natural to put this work into the view controller. In Cocoa’s version of MVC, view controllers are allowed broad flexibility in how they manage the views. (This is a significant place that Cocoa’s MVC differs from SmallTalk’s MVC, which it is based on.)

    But what if you want to share the same formatting between views (or view controllers)? Then you factor out the formatting code into an NSFormatter subclass (or use an existing NSDateFormatter in your case). You can pass these around, put then in ivars, or even create a Singleton to hold them.

    Why not just put it in the model in that case? Well, say you have four views that show the time this way, but you then add two other views that shows the time as 00:00.0, and then there’s one accumulator view that shows hours and minutes. Now you have to keep expanding the model to handle these cases. The model is picking up more and more information about the views. Keeping the formatting in a formatter allows you to share the code (and bug fixes) without polluting the model with these details. And views that have very special formatting needs can still have their own custom code.

    There’s no need to create separate NSFormatter subclasses for every kind of formatting. You can create a single MYObjectFormatter class that takes options like “hours,” “minutes,” “seconds,” etc. It would work just like an NSDateFormatter in this regard, and give the simplicity of use you need, while keeping your formatting code out of the model. This is exactly how NSDate and NSDateFormatter are partitioned.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a text area in my form which accepts all possible characters from
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I am trying to loop through a bunch of documents I have to put
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.