O'Reilly logo

Cocoa in a Nutshell by James Duncan Davidson, Michael Beam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

NSLocking — Mac OS X 10.0

Synopsis

This protocol is adopted by a class that implements lock objects. Locks are used in multithreaded applications to coordinate access to shared, thread-sensitive storage, or to control execution of critical portions of code (which usually deal with these same kinds of resources) that two or more threads may attempt to access simultaneously. The protocol declares two methods: lock and unlock. The lock message is used by clients to acquire a lock before executing critical sections of code, and the unlock method is used to relinquish a previously acquired lock.

The Foundation framework defines three classes that adopt the NSLocking protocol: NSLock, NSConditionLock, and NSRecursiveLock. See the class descriptions for these three classes, and Chapter 2 for more information.

@protocol NSLocking
                                  // Instance Methods
   - (void)lock;
   - (void)unlock;
@end

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required