Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Pointer to id



On 02/gen/06, at 12:08, Sanri Parov wrote:

mmmhhhh.....
I've tried doing this:

NSValue *value;
value = [NSValue valueWithPointer:@encode(PortAudioStream *)];
[value retain];
[NSThread detachNewThreadSelector: @selector(playForSure:) toTarget: nil withObject:value];

Don't use @encode with valueWithPointer. It takes an actual pointer, not a pointer type. Also, you shouldn't retain value, detachNewThreadSelector will take care of it. Use something like this:


PortAudioStream  *stream;

/* put code to initialize stream here */
[NSThread detachNewThreadSelector: @selector(playForSure:) toTarget:self withObject:[NSValue valueWithPointer:pas]];


assuming that the object which should handle the playForSure message is self; otherwise, change it as needed.

The selector should be like this:

- (void)playForSure:(NSValue *)streamValue;
{
	PortAudioStream  *stream;
	NSAutoreleasePool *pool;

	pool = [[NSAutoreleasePool alloc] init];
	stream = [streamValue pointerValue];

	/* put your code here */

	[pool release];
}

Camillo
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Pointer to id (From: Sanri Parov <email@hidden>)
 >Re: Pointer to id (From: Pontus Ilbring <email@hidden>)
 >Re: Pointer to id (From: Sanri Parov <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.