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,