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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:03:21+00:00 2026-06-13T08:03:21+00:00

I have an NSMutableArray that’s accessed primarily by the main thread in my iOS

  • 0

I have an NSMutableArray that’s accessed primarily by the main thread in my iOS game. Every 2-3 seconds I need to perform an expensive operation on this grid. I don’t need to modify the grid. I just need to do some calculations and return a result. How can I efficiently and safely use the grid in a background thread?

So far I’ve considered just copying the grid and passing it as the object in performSelectorInBackground. However this seems potentially wasteful. I’ve also considered just accessing the grid’s reference from the background thread and making sure the main thread doesn’t write to the grid until the background thread has finished processing. However this feels risky and I’m not sure if it’s a common practice.

  • 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-13T08:03:22+00:00Added an answer on June 13, 2026 at 8:03 am

    It all depends on if the game is going to have to stop / slow down if it can’t write to the grid. If it does, then it defeats the purpose of running it in the background. If the game can continue fine without writing to the grid then that is the best option. It isn’t dangerous as long as you make sure it doesn’t write until the background processing is done.

    If the game is going to be slowed down then I would go the copy route.

    Both of these things can be handled directly in the grid class (if that is where you are doing the processing). You can have a way to “lock” the grid and you can have the grid object queue up changes until the processing is done. When the processing is done you can loop through all the operations and apply them. This way everything can continue as normal even if the grid is locked.

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

Sidebar

Related Questions

I have a NSMutableArray that I need to search for a string and return
I have a NSMutableArray (tripHistory) that gets a NSMutableDictionary (currentUpdate) added to it every
Good day. I have an NSMutableArray that contains references to objects. I need to
I have an NSMutableArray that is populated with objects of strings. For simplicity sake
I have a NSMutableArray (called listOfSites) that is created and used in classA.m. I
I have an NSMutableArray called message that I've alloc'd in init and release in
I have been working with NSArray s and NSMutableArray s that store NSDate objects
I have a NSMutableArray and a NSArray . Both consist of elements that are
I have a class that has a method: -(NSInteger) getCityCountForState:(NSString *)state CityArray:(NSMutableArray *)cityArray {
I currently have a function written called saveWorkout that saves an NSMutableArray to another

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.