discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSThreading


From: Jamison Hope
Subject: Re: NSThreading
Date: Tue, 13 Nov 2012 17:08:05 -0500

That should be 'NSSelectorFromString(@"do_it:")' with the colon at the end.
At least, that fixes it compiling/running on Cocoa, so I assume it's the
same issue for GNUstep.. and it is, look at your error message:
> reason: -[obj1 do_it]: unrecognized selector

Jamie

On Nov 13, 2012, at 4:46 PM, Andor Kocsis <andor_kocsis@yahoo.com> wrote:

> Could someone help me plz with this simple program?
> 
> --------------------------------------------------------------
> #import <Foundation/Foundation.h> 
> 
> @interface obj1: NSObject { }
> -(void) do_it:(id)p1;
> @end
> 
> @implementation obj1
> -(void) do_it:(id)p1 {
>   NSAutoreleasePool* pool= [[NSAutoreleasePool alloc] init];
>   NSLog(@"obj1#tick");
>   [pool drain];}
> @end
> 
> int main (int argc, const char * argv[]) {
>   NSAutoreleasePool* pool= [[NSAutoreleasePool alloc] init];
>   obj1* obj= [[obj1 alloc] init];
>   [NSThread detachNewThreadSelector:
>       NSSelectorFromString(@"do_it")
>       toTarget:obj withObject:obj];
>   NSLog(@"main#tick");
>   [NSThread sleepForTimeInterval:0.5];
>   [pool drain];
>   return 0;}
> 
> -------------------------------------------------------------------------
> 
> Program's output:
> -------------------------------------------------------------------------
> 2012-11-13 22:39:20.820 helloworld[2900] autorelease called without pool for 
> obj
> ect (0x749c58) of class GSCInlineString in thread <NSThread: 0x749b68>
> 2012-11-13 22:39:20.789 helloworld[2900] WARNING - unable to create shared 
> user
> defaults!
> 2012-11-13 22:39:20.836 helloworld[2900] main#tick
> 2012-11-13 22:39:20.836 helloworld[2900] autorelease called without pool for 
> obj
> ect (0x749400) of class NSException in thread <NSThread: 0x749b68>
> 2012-11-13 22:39:20.851 helloworld[2900] autorelease called without pool for 
> obj
> ect (0x36bc358) of class GSMutableArray in thread <NSThread: 0x749b68>
> helloworld.exe: Uncaught exception NSInvalidArgumentException, reason: -[obj1 
> do
> _it]: unrecognized selector sent to instance 0x748690
> 
> This application has requested the Runtime to terminate it in an unusual way.
> Please contact the application's support team for more information.
> 
> -------------------------------------------------------------------------
> 
> 
> Using latest SDK on Windows. There isn't any compile time error or warning. 
> How to fix this simple NSThread example to run properly?
> 
> Thx,
> _______________________________________________
> Discuss-gnustep mailing list
> Discuss-gnustep@gnu.org
> https://lists.gnu.org/mailman/listinfo/discuss-gnustep

--
Jamison Hope
The PTR Group
www.theptrgroup.com






reply via email to

[Prev in Thread] Current Thread [Next in Thread]