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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:26:32+00:00 2026-05-24T18:26:32+00:00

My app often crash when draw a view with some plot. To keep interface

  • 0

My app often crash when draw a view with some plot. To keep interface responsive while I calculate data for plot I use threads.

dispatch_async(dispatch_get_main_queue(), ^{
    [activity startAnimating];
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, NULL), ^{
     //  do a lot of calculation   
        [GraphView calculateViewData];
        dispatch_async(dispatch_get_main_queue(), ^{
           //  draw plot 
           [GraphView setNeedsDisplay];    
           [activity stopAnimating];
        });
    });
});

in calculateViewData I fill some arrays which will use later in drawRect. When user click on interface buttons that run code above too fast my app crashes. As I understand while app draw plot in main thread calculateViewData changes arrays in another thread. As result I always crash on this error [__NSArrayI objectAtIndex:] in drawRect

What can I do to fix it? Is copying objects can help in this case?

  • 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-24T18:26:35+00:00Added an answer on May 24, 2026 at 6:26 pm

    You can’t manipulate data on one thread and then attempt to utilize that changing data on another. Instead, you do all your manipulations on a background thread and then notify the frontmost/main thread when the manipualtions complete.

    Based on your previous questions, you are using Core Data so I recommend reading up on Concurrency in Core Data.

    Background processing lets the UI remain responsive but that doesn’t mean you are actually doing two things at once. You have to let data processing finish before you use the data regardless of what thread the processing takes place on.

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

Sidebar

Related Questions

I have a multithreaded app that has to read some data often, and occasionally
I often store application config data in an app.config file in the following format:
I have a scroll view and I need to reload the contents often while
I'm upgrading an app to Rails 3.1. Quote often, Firebug will complain about some
my app crashes often in this for-loop: for (int a = 0; a <=
In my SWT Java app I often want to return information from inside a
Using Terminal.app on OS X 10.5, often you see the commands get garbled when
When supporting a new web app in an enterprise environment, it is often necessary
I'm developing a Cocoa app, and every so often when running my app in
When using an HttpConnection in a BlackBerry app, you often get HTTP cookies in

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.