@synchronized question
@synchronized question
- Subject: @synchronized question
- From: Mel Walker <email@hidden>
- Date: Mon, 24 May 2004 10:15:36 -0600
I'm a little unclear about how @synchronized works. Can someone tell me
if I have this right?
For example, I have code that looks like this (logLock is an NSLock,
myTextView is a NSTextView):
-(void)doSomething {
[logLock lock];
...
[myTextView scrollRangeToVisible:scrollRange];
[myTextView setNeedsDisplay:YES];
[logLock unlock];
}
can I replace this with the following:
-(void)doSomething {
@synchronized(myTextView) {
[myTextView scrollRangeToVisible:scrollRange];
[myTextView setNeedsDisplay:YES];
}
}
or should I do something like this:
-(void)doSomething {
@synchronized(self) {
[myTextView scrollRangeToVisible:scrollRange];
[myTextView setNeedsDisplay:YES];
}
}
Thanks,
Mel Walker <email@hidden>
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.