I am developing an application for showing the filesystem contents . I have two types of displays
1)OutlineView
2)IKImagebrowserView
The user can switch between the views . I am maintaining the current view object in a global variable currentview as multiple controllers need to access it.
Now whenever the user switches views, one controller (running on a thread) changes this global variable. However I have another controller which (depending on some DB operation) continuously refreshes the currentview using
[currentview reloadData];
Now whenever I switch rapidly between the views, there is an issue with the currentviewobject among these threads and the application crashes.
The crash report shows that the aplication crashes on the line
[currentview reloadData];
Is there any solution for this ??
try using
this will make a exclusive lock which will prevent it from being accessed by other threads simultaneously.