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

  • SEARCH
  • Home
  • 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 8886157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:29:22+00:00 2026-06-14T21:29:22+00:00

Coming from a web development background, doing mainly MVC-based applications, I am used to

  • 0

Coming from a web development background, doing mainly MVC-based applications, I am used to have the components of my code separated in three groups of files: the controllers, the models and the views.

But in a iOS application, even also using the MVC pattern, does it make sense to follow the same technique?

An UIViewController provides you with a default view where you can add the rest of the subviews (UILabel, UIButton,…) and have immediate access to them. And the language is the same, it’s not like having to deal with HTML/CSS and something else.

But I have came across some iOS applications where an UIView is subclassed and maintained in a separate file, even when it’s only going to be used in an UIViewController. Thus, you have to code custom accessors to deal with internal subviews.

I do not see the need for doing that, unless of course you are reusing the same UIView in several places or doing custom drawing.

  • 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-06-14T21:29:24+00:00Added an answer on June 14, 2026 at 9:29 pm

    Many of us will admittedly blur the MVC lines a little and will slip a tiny amount of view-related code into our controllers. I personally think that is fine. It does not diminish the fact that we’re still largely following the MVC pattern (and that the Cocoa classes are doing the heavy lifting for the view). But, for me, if the view-related code expands beyond the trivial, I find myself electing to subclass the view.

    There will be people who religiously subclass UIView, but I think a little pragmatism is warranted. If you’re adding a trivial amount of view-related code, is your code legibility improved by abstracting that away into a new UIView subclass? Not always. But I think this situation (where someone subclasses when they probably didn’t need to) is far less common than the opposite problem (where someone failed to subclass when they probably should have).

    So, you asked:

    I do not see the need for doing that [subclassing UIView], unless of course you are reusing the same UIView in several places or doing custom drawing.

    I agree that reuse and custom drawing (e.g. drawRect) are two great examples. But I would also add a principle that if subclassing would improve code legibility because a view is sufficiently complicated (admittedly a subjective call), then I will subclass. Two examples:

    1. I had a calendar view in an app and the view controller was getting unwieldy, managing all of the cells for the various days in the month, etc. So by subclassing the UIView, I was able to abstract the ugly details of all of the subviews that composed by calendar view. I subclassed not only the main “month” view, but also the “day” views within the “month” view. No reuse per se. No custom drawing. But it was obviously the right thing to do. The code is infinitely more legible.

    2. I increasingly subclass UITableViewCell for my table views. In my first projects, I’d have the table view controller’s cellForRowAtIndexPath do all of the complicated composition and layout of that cell. My code is far easier to follow now that I routinely subclass the UITableViewCell in any situation that I’m not using one of the standard cell types.

    In short, while I agree that one shouldn’t feel forced to subclass a UIView for every view controller, I personally try to do so when a view reaches a certain level of complexity. I let the code legibility govern my practices. I find that I’m subclassing views more than I used to, but by no means am I doing it all the time.

    Bottom line, while you don’t need to subclass views all the time, I personally think many developers are guilty of failing to subclass views (or models) when they should have. They shouldn’t do so out of some fanatical desire to conform to MVC, but rather they should be asking themselves if their code would be easier to read and maintain if they subclassed the view or model as appropriate.

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

Sidebar

Related Questions

I recently got interested in web development coming from kernel based applications. I am
Coming from a Web Development background I am now into QT Applications development. Working
I'm new to iPhone development, coming from a web application development background and I'm
I'm coming to iOS development from a web dev background. Having all of my
I'm coming from a web-development background and I am wondering how I would make
I am new to web programming, coming from a video game development background (c++),
I am trying to learn web development using Mono. Coming from ASP.NET background, I
I'm pretty new to mac development (coming from a web and iOS background) and
Coming from web development I have been trying to get familiar with compiled programming,
I have implemented UIWebView and displaying the contents coming from web services,Here is the

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.