My goal is to initialize a large amount of data on a different (non-main) thread, and then refresh a UIProgressView
on the main thread corresponding to the large data load's progress. To do this, I use performSelectorInBackground
to load the data, and update the progress throughout the way using performSelectorOnMainThread
.
I am currently getting a EXE_BAD_ACCESS
error from one of the dictionaries that I am initializing, specifically the line where I am setting self.someDictionary = @{...}
. self.someDictionary
takes on strong
and nonatomic
properties, and is initialized on the non-main thread.
As a total newbie to multithreading, I am beginning to see that I shouldn't be setting a strong and nonatomic
property (however, changing it to atomic
still caused the crash). What else am I doing incorrectly to cause the EXE_BAD_ACCESS
error, and how do I set a large amount of data to an NSDictionary on a non-main thread and still be able to update the progress on the main thread?
Thanks!
Edit 1:
Code:
//In viewWillAppear, from the main thread
[self performSelectorInBackground:@selector(populateDictionaries) withObject:nil];
//In populateDictionaries method
Dictionary *someDictionary = [[Dictionary alloc] init];
//the methods inside the Dictionary class
- (id) init{
self = [super init];
if (self){
[self makeDictionaries];
}
return self;
}
- (void)makeDictionaries{
self.insiderDictionary = @{ ...} //this line is causing the crash
}