• 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
new to Cocoa -- threading question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

new to Cocoa -- threading question


  • Subject: new to Cocoa -- threading question
  • From: John Michael Zorko <email@hidden>
  • Date: Sat, 06 Sep 2008 18:35:54 -0700


Hello, all ...

I'm new to Cocoa, and i'm trying to launch a thread. Yet, the app bombs when I try, and the console says it's because the selector isn't implemented:

2008-09-06 18:23:30.919 XXX[2363:20b] SEL: playMP3StreamThread
2008-09-06 18:23:30.927 XXX[2363:20b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** - [NSThread initWithTarget:selector:object:]: target does not implement selector (*** -[XXXAppDelegate playMP3StreamThread])'


Yet, here it is -- i'm not understanding something obviously (the example I saw looked easy enough):

@implementation XXXAppDelegate

.
.
.

- (void)playMP3StreamThread:(Song *)streamToPlay
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

// initialize a mutex and condition so that we can block on buffers in use.

pthread_mutex_init(&myData.mutex, NULL);
pthread_cond_init(&myData.cond, NULL);

OSStatus err = AudioFileStreamOpen(&myData, MyPropertyListenerProc, MyPacketsProc,
kAudioFileAAC_ADTSType, &myData.audioFileStream);
if (err)
{
NSLog(@"AudioFileOStreamOpen error %d", err);
}

NSString *url = @"http://some_hostl/";;
url = [url stringByAppendingString:streamToPlay.mp3];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:[url stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];

if (connection)
{
receivedData = [[NSMutableData data] retain];
}
else
{
NSLog(@"can't connect to server");
}

[pool release];
}



- (void)playStream:(Song *)streamToPlay
{
NSLog(@"playing mp3 stream %s", [streamToPlay.mp3 UTF8String]);

// make sure current song play thread is stopped ...






// start a new thread with the new song ...

[NSThread detachNewThreadSelector:@selector(playMP3StreamThread) toTarget:self withObject:streamToPlay];
}


What am I not grokking?  Any pointers would be appreciated ...

Regards,

John




_______________________________________________

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


  • Follow-Ups:
    • Re: new to Cocoa -- threading question
      • From: Mike Abdullah <email@hidden>
    • Re: new to Cocoa -- threading question
      • From: "Kyle Sluder" <email@hidden>
  • Prev by Date: Re: How to create a GUID?
  • Next by Date: Re: new to Cocoa -- threading question
  • Previous by thread: Re: How to create a GUID?
  • Next by thread: Re: new to Cocoa -- threading question
  • Index(es):
    • Date
    • Thread