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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:05:11+00:00 2026-05-20T03:05:11+00:00

So I want to know if this is a good idea or a bad

  • 0

So I want to know if this is a good idea or a bad idea.

I’m building a simple iOS game (using standard UI Controls) which allows a user to create Characters, and Monster “Templates”, then build Encounters which references Characters and Monsters and interact with them.

When the user creates an encouner, there is a simple Modal View which allows them to name the encounter, then push to another VC to select the characters participating, go back, push to a second view controller to select the Monster Templates involved, as well as how many of those monsters will be participating.

The goal, in the end, is to have the Monster Templates be used to construct “real” monsters that will be references in the Encounter.

Sample Encounter
  Player Characters
    Ramza Beoulve
    Delita Hiral
  Monsters
    Orc 1
    Orc 2
    Orc 3

For the character selection piece, I used an NSSet to store the Character Entities selected and pass it between view controllers. (This way I avoid having to mess with the managed object context very much prior to actually saving the new encounter)

For the monsters, since I need to store a quanitity as well as the entity, it’s a little more complicated.

So my original thought was to store them in an NSArray of NSDictionaries which in turn contain the Monster Template and the Quantity.

The problem with that approach is I have to loop through the NSArray and open each individual dictionary to check if a particular monster template exists or not.

It might not matter much at this scale of application, but it seems inefficient.

So I thought instead it might be better to simply maintain two NSMutable Arrays

NSMutableArray *selectedMonsterTemplates;
NSMutableArray *selectedMonsterTemplateQuantities;

This way I can simply call

[selectedMonsterTemplates containsObject:monsterTemplate]; 

when I need to check if something is already in there, and when I add or subtract the quantity for a particular monster, I can simply update both Arrays.

Then when the Encounter is saved I can simply iterate over the Array once to create my individual monster instances in the quantity desired, and associate them with the Encounter.

I’m concerned that this approach, while simple and efficient, might lead to concurrency problems if there is a small mistake in the code. Is there a better way to go about this?

  • 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-20T03:05:12+00:00Added an answer on May 20, 2026 at 3:05 am

    Maybe its a better design to add a class, lets say TemplateStore. (Or whatever you like)

    @interface TemplateStore : NSObject {
       MonsterTemplate *template; //Super class of a monster entity. 
       NSInteger quantity;
    }
    
    - (id) initWIthMosterTemplate:(MonsterTemplate *)temp;
    - (void) increaseQuantity;
    - (BOOL) isKindOfTemplate:(MonsterTemplate *)otherTemp;
    
    @property (readonly, retain) MonsterTemplate *template;
    @property NSInteger quantity;
    
    @end
    

    WHen you store this kind of object in an array, you can iterate over it and use the isKindOfTemplate method to know if the MonsterTemplate exists. Then just increase the quantity.

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

Sidebar

Related Questions

i just want to know a general information about this particular information. Any good
I want to know if this web app are using long polling or anything
I want to know this more in detail. Is it a realtime scheduler? An
I want to know how this theme gets the effect of the items in
I want to know what this looks like. I don't have any ideas about
I just want to know why this doesn't work (I am trying to name
I know this is a n00b question but I want to define a variable
I know this question is probably stoopid. But I just don't want to cause
I know there is this post , but I still want to know more
I want to style my custom scrollbar. I know this is possible with WebKit,

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.