Re: Thread safety with background fetching

2008-07-31 Thread Joseph Kelly
Jens response just reminded me to check the docs, and it says of - performSelectorOnMainThread:...: "This method retains the receiver and the arg parameter until after the selector is performed" So I retract what I said before. So long as, was noted, you do not mess with the passed object

Re: Thread safety with background fetching

2008-07-31 Thread Phil
On Fri, Aug 1, 2008 at 4:59 AM, Ben <[EMAIL PROTECTED]> wrote: > and then -[XMLFetcherParser doYourThing] repeatedly sends newly created > objects to receiveItem: using the performSelectorOnMainThread method. Once > the spawned thread has done this, it never uses the sent object again. > > > My que

Re: Thread safety with background fetching

2008-07-31 Thread Jens Alfke
On 31 Jul '08, at 9:59 AM, Ben wrote: For usage, the summary is that I do: [NSThread detachNewThreadSelector:@selector(doBackgroundFetch) toTarget:self withObject:nil]; and then -[XMLFetcherParser doYourThing] repeatedly sends newly created objects to receiveItem: using the performSele

Re: Thread safety with background fetching

2008-07-31 Thread Joseph Kelly
The only time you're sharing data across threads is via - performSelectorOnMainThread:... which itself is thread safe. So the main thing you have to work through is the memory management of the data which XMLFetcherParser is passing to the -receiveItem: method on the main thread. The convent

Thread safety with background fetching

2008-07-31 Thread Ben
Hi List, Having read the Apple documentation and beginner guides on threading, I am still a little confused about protecting my variables from access by multiple threads. A sample of my code is as follows: @interface Class1 : NSObject { XMLFetcherParser *fetcherParser; } - (void)do