Accessing Instance Attributes from Secondary Thread (iPhone-SDK)

Posted by Travis on Stack Overflow See other posts from Stack Overflow or by Travis
Published on 2010-03-08T06:46:18Z Indexed on 2010/03/08 6:51 UTC
Read the original article Hit count: 1268

Filed under:
|
|

I have a class with an NSDictionary attribute. Inside this class I dispatch another thread to handle NSXMLParser handling. Inside my -didStartElement, I access the dictionary in the class (to compare an element found in the XML to one in the dictionary).

At this point I get undefined results. Using NSLog (I'm not advanced in XCode debugging), I see that it bombs around access of the NSDictionary. I tried just iterating the dictionary and dumping the key/values inside the didStartElement and this bombs at different keys each time.

The only thing I can conclude is that something is not kosher that I'm doing with regards to accessing main thread attributes from the secondary thread. I'm somewhat new to multithreading and am not sure what the best protocol is safely access attributes from additional threads.

Thanks all.

© Stack Overflow or respective owner

Related posts about iphone-sdk

Related posts about nsthread