NSSound: Why Doesn't This Work?
NSSound: Why Doesn't This Work?
- Subject: NSSound: Why Doesn't This Work?
- From: Michael Urban <email@hidden>
- Date: Sat, 02 Nov 2002 18:44:33 -0500
Why does the following program never terminate? I could swear it used
to in 10.0 or thereabouts....
#import <Cocoa/Cocoa.h>
#include <sys/types.h>
#include <sys/stat.h>
int main (int argc, const char *argv[])
{
struct stat sb;
NSAutoreleasePool *pool =[[NSAutoreleasePool alloc] init];
NSSound *mysound = [NSSound alloc];
if (argc != 2) {
fprintf (stderr, "Usage: %s soundfile\n", argv[0]);
return 1;
}
if ( stat(argv[1], &sb) != 0) {
perror(argv[1]);
return 1;
}
[mysound initWithContentsOfFile: [NSString stringWithCString: argv[1]]
byReference: YES];
[mysound play];
while ([mysound isPlaying]) {
sleep(2);
}
[pool release];
return 0;
}
_______________________________________________
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.