So my potential solution for this is: NSSpellChecker *checker = [NSSpellChecker sharedSpellChecker]; __block NSRange range = NSMakeRange(0, 0); while (range.location < [aString length]) { dispatch_sync(dispatch_get_main_queue(), ^{ range = [checker checkSpellingOfString:aString startingAt:range.location]; });
// update range } Where this piece of code will run on multiple threads. Does this look like a reasonable approach to ensuring thread safety? Martin On 17, Jul, 2012, at 06:33 PM, Martin Hewitson <martin.hewit...@aei.mpg.de> wrote: > > On 17, Jul, 2012, at 05:26 PM, Fritz Anderson <fri...@manoverboard.org> wrote: > >> >>> Could the problem be that I'm using the shared spell checker on multiple >>> threads? >> >> YES. At least it's a very big item on your list of problems. I haven't found >> any documentation that affirmatively says NSSpellChecker is thread-safe. >> Therefore it isn't. It's in AppKit, which counts against it, and it manages >> a UI facility, which excludes it. > > Oh, that's not good. I wanted to be spell checking multiple files in the > background. I will need to think carefully if there's a way to call > -checkSpellingOfString:startingAt on the main thread. > > Martin > >> >> Try executing your checks on the main thread. Communicating the results to >> the calling thread will require some care. >> >> — F >> >> -- >> Fritz Anderson -- Xcode 4 Unleashed: Now in stores! -- >> <http://x4u.manoverboard.org/> >> > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Martin Hewitson > Albert-Einstein-Institut > Max-Planck-Institut fuer > Gravitationsphysik und Universitaet Hannover > Callinstr. 38, 30167 Hannover, Germany > Tel: +49-511-762-17121, Fax: +49-511-762-5861 > E-Mail: martin.hewit...@aei.mpg.de > WWW: http://www.aei.mpg.de/~hewitson > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Martin Hewitson Albert-Einstein-Institut Max-Planck-Institut fuer Gravitationsphysik und Universitaet Hannover Callinstr. 38, 30167 Hannover, Germany Tel: +49-511-762-17121, Fax: +49-511-762-5861 E-Mail: martin.hewit...@aei.mpg.de WWW: http://www.aei.mpg.de/~hewitson ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com