My Thread Programs Crash
Posted
by zp26
on Stack Overflow
See other posts from Stack Overflow
or by zp26
Published on 2010-04-13T14:50:49Z
Indexed on
2010/04/13
14:52 UTC
Read the original article
Hit count: 274
I have a problem with threads objectiveC. The line of code below contains the recv block the program waiting for a datum. My intention is to launch a thread parallel to the program so that this statement does not block any application. I put this code in my program but when active switch the program crashes. Enter the code.
-(IBAction)Chat{
if(switchChat.on){
buttonInvio.enabled = TRUE;
fieldInvio.enabled = TRUE;
[NSThread detachNewThreadSelector:@selector(riceviDatiServer) toTarget:self withObject:nil];
}
else {
buttonInvio.enabled = FALSE;
fieldInvio.enabled = FALSE;
}
-(void)riceviDatiServer{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
int ricevuti;
NSString *datiRicevuti;
ricevuti = recv(temp, &datiRicevuti, datiRicevuti.length, 0);
labelRicezione.text = [[NSString alloc] initWithFormat:@"%s.... %d", datiRicevuti, ricevuti];
[pool release];
}
© Stack Overflow or respective owner