Re: NSCondition easter-egg hunt
Re: NSCondition easter-egg hunt
- Subject: Re: NSCondition easter-egg hunt
- From: "Adam R. Maxwell" <email@hidden>
- Date: Thu, 03 Apr 2008 19:01:32 -0700
On Thursday, April 03, 2008, at 06:15PM, "Jack Repenning" <email@hidden> wrote:
>So, what's the scoop on NSCondition? Can someone lead me out of the
>woods? I can't formulate a coherent question, only a list of bits of
>documentation which appear to me to contradict each other every way
>from Sunday. Am I misreading something, or are some few of these wrong?
>
>(1) When did NSCondition come to be? Cocoa Fundamentals Guide (as
>contained in my Leopard Xcode) has a Note: "The NSCondition class was
>introduced in Mac OS X v10.5. It is not available in earlier versions
>of the operating system."
The Foundation release notes say that it's available since before 10.0, so it's safe to use on any OS version. Since the API doc also says it's available on 10.0, I'd guess the statement above is wrong. I think I've seen mention of it elsewhere as a private class.
>(2) What are its methods? Thread Programming Guide's "Using the
>NSCondition Class" section shows examples with the methods -lock, -
>wait, -signal, and -unlock. The reference manual lists -wait, -
>waitUntilDate:, -signal, -broadcast, -setName:, and -name (nothing
>about lock, an odd omission for a semaphore class). None of these
>mention any special initializers. If I create one:
The API doc says that it conforms to <NSLocking>, which declares lock and unlock.
> NSCondition *theCondition = [[NSCondition alloc] init];
>
>and then try these various names (for example, [theCondition lock]), I
>get "method not found" on -broadcast, -wait, -signal, -waitUntilDate:,
>and -setname: -- everything except -lock, -name, and -unlock.
Odd. The following works for me on 10.5:
// compile with: cc condtest.m -framework Foundation -o condtest
#import <Foundation/Foundation.h>
int main (int argc, char const *argv[])
{
NSAutoreleasePool *pool = [NSAutoreleasePool new];
NSCondition *cond = [[NSCondition alloc] init];
[cond lock];
[cond signal];
[cond broadcast];
[cond unlock];
[pool release];
return 0;
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden