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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:55:31+00:00 2026-05-20T18:55:31+00:00

In my program, I have a class called Object, which inherits from UIView. I

  • 0

In my program, I have a class called Object, which inherits from UIView. I also have other objects called: circle, square, triangle which inherit from Object.

My problem is that I would like to make a possible object called Image, which also inherits from Object. I would like all objects on the screen to inherit from Object, and then pass an NSArray pointer to my physics functions that contains all objects on the screen.

What is the best way to have my Image object acquire all the properties of my Object class?

Should I just create new properties for my Image object, or is there a way to inherit Object and still be able to display an image, since Object inherits from UIView and not UIImageView.

  • 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-20T18:55:32+00:00Added an answer on May 20, 2026 at 6:55 pm

    That’s a very…unusual way to do it. Have you had any Java experience?

    What are you trying to do with the Shapes? Are you trying to draw them in those respective classes? Here, you’re blurring the lines of MVC. From what it seems like, your Circle, Square, etc. classes are both a model and a view, which shouldn’t happen. If you’re trying to draw the shapes, you wouldn’t create classes for them—you’d use the Quartz drawing methods to draw them in your view controller’s view. If you’re trying to store info about those shapes, you wouldn’t want them to inherit from UIView. NSObject (or a custom Shape class) would be a better option. (It’s also a bad idea to call the class “Object”—it could get confused with NSObject).

    You’re second paragraph is where my first question came from. Your NSArray does not have to contain variables of the same type—this is very different from Java’s arrays (and other languages such as C# and C). Therefore, unless there were some methods or ivars you wanted to inherit, there was no reason to declare the Object class.

    As for displaying images, what are you intending to do with Image? If you just want to display images (a view), then make it a subclass of UIImageView (which is a subclass of UIView). If you want do store information about images, make it a subclass of Shape (or in this case, your Object). However, you really can’t do what you want to (inherit from both Object and UIImageView) because you shouldn’t combine functionality of views and models.

    Really, your best option here is to revisit your classes, make them adhere to MVC, and rethink your inheritance chain. Hope this helps!

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

Sidebar

Related Questions

I have a Java program that loads thirdparty class files (classes I did not
I have the following in a program (written in VB.NET): Imports Microsoft.Office.Interop.Excel Public Class
In a C# program, I have an abstract base class with a static Create
I have the following code: using System; using System.Linq; using System.Linq.Expressions; public class Program
Okay here's the program I have typed up(stdio.h is included also): /* function main
Most program languages have some kind of exception handling; some languages have return codes,
in a C program I have an long* that I want to serialize (thus
In my program I have one array with 25 double values 0.04 When I
I want to turn a program I have into a service so I can
I have a program that spits out both standard error and standard out, and

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.