• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
@synchronized question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

@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.


  • Follow-Ups:
    • Re: @synchronized question
      • From: Shawn Erickson <email@hidden>
    • Re: @synchronized question
      • From: Clark Cox <email@hidden>
  • Prev by Date: Re: [firstPath appendBezierPath: [secondPath bezierPathByReversingPath]];
  • Next by Date: Calling an Action from a function
  • Previous by thread: Re: Textured palettes / draggable regions
  • Next by thread: Re: @synchronized question
  • Index(es):
    • Date
    • Thread