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 7569341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:08:28+00:00 2026-05-30T15:08:28+00:00

I have an iOS app working and am trying to clean up some of

  • 0

I have an iOS app working and am trying to clean up some of the code structure and implementation. I’d like to clarify my understanding of MVC and improve my code.

Question: is it legit to pass a model to a UIView so the view can render it based on the states of the model elements?

I outline an example below but realize it may not be clear, too tedious to read, etc. The gist is: if a UIView doesn’t change any values in a model, is it ok that it retains a weak reference to the model? (say compared to always asking its delegate to return a temporary pointer to the model).

–thanks for any comments!

Example: imagine a UIView which represents a 10 story BUILDING with 1 WINDOW on each floor. The MODEL for this is an NSArray containing 10 instances of custom WINDOW objs. Each WINDOW obj. has a state (light on or off) and a CGRect representing the position of the WINDOW within the overall building view rect.

The controller for the BUILDING instance defines the size of the building view (it’s frame) and all the WINDOW objs, including the CGRects,it’s state etc., creating the NSArray MODEL. I then assign this MODEL to the UIView for the BUILDING controller (but retain is as a strong property of the BUILDING controller).

The UIView needs to know about the state of the WINDOW and the CGRect in order to draw the view in drawRect.

I guess I could store the CGRects separately since they are not abstract data but it seemed easier to pack it all into one array of objects.

  • 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-30T15:08:30+00:00Added an answer on May 30, 2026 at 3:08 pm

    You’re on the right track. But there is no reason for the view to have a “weak” reference to the model. It is appropriate for it to have a strong reference to the piece of the model that it is actually displaying, unless you want the piece of model data to be able to vanish while it’s being displayed. That would be unusual.

    Say I have this thing called WindowPaneView that displays a WindowPane (just avoiding any confusion with UIWindow here). There is nothing wrong with the controller creating the view and handing it a strong reference to the WindowPane. That is a very good design in many cases.

    What would be wrong is for the WindowPaneView to make requests to the Building to get the correct window information. The controller should talk to the Building, divvy up the information, and hand each WindowPaneView its proper Window.

    It would also be wrong for the WindowPane to know anything about the WindowPaneView. The model must never, ever, know about the views. Madness quickly descends when that happens. But views may certainly know about the specific piece of the model that they are directly displaying. Just no more.

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

Sidebar

Related Questions

I'm working on an iOS app and have had some trouble with getting photos
Ok, I have been trying to get my ios app working with the facebook-ios-sdk.
I have an iOS app in the app store. I'm working on some new
I have been working on an iOS App for sometime now and its almost
We have been working for several months on a fairly substantial iOS app using
I'm working on an iOS web app and I have the viewport set to
I am working on a sample map kit app for iOS. I have everything
I have an app working with databases on both server side and iOS client
I'm working on mobile (Android/iOS) app, which will integrate with FB and have a
I'm trying to copy the iOS Safari bookmark system. I have individual bookmarks working

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.