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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:38:10+00:00 2026-05-26T13:38:10+00:00

I am trying to create a model with multiple images in a factory model

  • 0

I am trying to create a model with multiple images in a factory model style. I have one class that handles the individuals, one class that handles the group of individuals and a ViewController.

testImage = [[UIImageView alloc] initWithFrame:CGRectMake(250, 500, 30, 30)];
testImage.image = [UIImage imageNamed:@"myImage.png"];
testImage.animationDuration = 1.5;
testImage.contentMode = UIViewContentModeCenter;
[self.view addSubview:testImage];

http://jcdeveloperworld.blogspot.com/2009/07/iphone-game-tutorial-part-1.html — Thanks

That code works when it is just in the viewController, and now I am trying to make the individuals keep track of their own image. So i put the

testImage = [[UIImageView alloc] initWithFrame:CGRectMake(250, 500, 30, 30)];
testImage.image = [UIImage imageNamed:@"myImage.png"];
testImage.animationDuration = 1.5;
testImage.contentMode = UIViewContentModeCenter;
[self.view addSubview:testImage];

in a separate class and then tried to display it from my viewController. It is my understanding that I can’t just tell the viewController to display something from a separate class.

   flock *newFlock = [[flock alloc] init];
[newFlock makeFlock];


NSMutableArray *tempFlock = [[NSMutableArray alloc] init];
tempFlock = newFlock.theFlock;

individualsClass *tempIndividual = [[individualsClass alloc] init];
tempIndividual = [tempFlock objectAtIndex:0];

UIImageView *tempImage = [[UIImageView alloc] initWithFrame:CGRectMake(250, 500, 30, 30)];

tempImage = tempIndividual.individualImage;

[self.view addSubview:tempImage];

I also tried it without all the copying, but the dot notation started to get in the way because I’m accessing properties of objects in an NSMutableArray (which seems absurdly difficult in objective C). I could use some help in figuring that out too

ie.

flock.[theFlock.individualImage.image objectAtIndex:1] //Doesn't work

I am kind of new to objective C, so perhaps I’m attacking this problem wrong. This is being done for an iPad app

  • 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-26T13:38:10+00:00Added an answer on May 26, 2026 at 1:38 pm

    It’s not clear what you’re trying to do, but you’re definitely doing a lot of stuff you don’t need to. Consider these lines of your code:

    NSMutableArray *tempFlock = [[NSMutableArray alloc] init];
    tempFlock = newFlock.theFlock;
    

    The first line declares a variable named tempFlock of type NSMutableArray *. Then it creates and initializes an empty NSMutableArray and assigns it to tempFlock. The second line then assigns newFlock.theFlock to tempFlock, overwriting the only reference to the array you created in the first line. You can just say this:

    NSMutableArray *tempFlock = newFlock.theFlock;
    

    Anyway, the correct syntax for your last block is this:

    [flock.theFlock objectAtIndex:1].individualImage.image
    

    So maybe this is what you want to do:

    [self.view addSubview:[flock.theFlock objectAtIndex:1].individualImage];
    

    Also, flock and individualsClass are not good class names in Objective-C. Flock and Individual might be better names.

    And it’s confusing that flock instances have a property named theFlock. It looks like theFlock is just an array of individuals, so a better name for the property would probably be individuals.

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

Sidebar

Related Questions

I'm trying to create a Django model that handles the following: An Item can
I'm trying to create models that represent a swiss tournament , with multiple rounds.
I'm trying to create an interface for a model class in ASP.NET MVC2 and
I'm trying to create a REST web service that exposes the following Django model:
I am trying to create a separate model class for image uploading, which was
I am trying to create a class say MyStack that would implement a java.util.collections
I am trying to send an email to multiple users. I have a model
I am trying to create an ActiveRecord model called 'Search' without a table. I
I am trying to create a mapping file for the following Model using Fluent
At the moment I'm trying to create a kind of model in vb.net which

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.