• 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
NSSound: Why Doesn't This Work?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: NSSound: Why Doesn't This Work?
      • From: "Ben Kennedy" <email@hidden>
  • Prev by Date: Re: metallized interface (offtopic rant)
  • Next by Date: Re: Getting hitTest of Subview
  • Previous by thread: Re: What happened to NSConvertWindowNumberToGlobal
  • Next by thread: Re: NSSound: Why Doesn't This Work?
  • Index(es):
    • Date
    • Thread