• 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
Re: How to interrupt a function
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to interrupt a function


  • Subject: Re: How to interrupt a function
  • From: Andrea Salomoni <email@hidden>
  • Date: Wed, 30 Nov 2005 15:39:06 +0100

Hi and Thank you,

the problem is the secondary thread...

-(void)startConnection:(id)owner
{
NSAutoreleasePool * myPool=[[NSAutoreleasePool alloc]init];
[conditionLock lockWhenCondition:CONNECTION];
NSLog (@"start connection");
if (![sckt isConnected])
{
sckt = nil;
int portw = 4321;
NSString * host = [NSString stringWithString:IPUS];

sckt = [Socket socket];
[sckt retain];
[sckt setBlocking:YES];
[sckt connectToHostName:host port:portw];

if ([sckt isConnected])
{
[conditionLock unlockWithCondition:CHECK_SOCKET];
[aTextView insertText:@"Connected\n"];

/*time = [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector: @selector(onTimer:)
userInfo: nil
repeats: YES];*/
}
else
{
return ;
[theError displayError:@"Server non connesso"];

}
}


[myPool release];
[NSThread exit];
}

If the connection failed ... I have to stop the thread before getting this error:
[Session started at 2005-11-30 15:37:39 +0100.]
2005-11-30 15:37:41.897 test[710] start connection
2005-11-30 15:37:41.909 test[710] An uncaught exception was raised
2005-11-30 15:37:41.909 test[710] Socket: Not connected
2005-11-30 15:37:41.909 test[710] *** Uncaught exception: <Socket: Not connected> Socket: Not connected



Thanks again Andrea Il giorno 30/nov/05, alle ore 15:36, Colin Barrett ha scritto:

You can technically return; in a void function.

But I would re-examine your flow if you have to do that.

-Colin

On Nov 30, 2005, at 9:33 AM, Andrea Salomoni wrote:

Hi to all,

I need a simple way to interrupt a function returning void.

-(void)method:(NSString*)aString
{
if (condition)
	{

}
else
	{

something like exit....
}
}

Anyone can tell me how to do?

Thank you all
Andrea

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden



_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: How to interrupt a function
      • From: j o a r <email@hidden>
    • Re: How to interrupt a function
      • From: "I. Savant" <email@hidden>
References: 
 >How to interrupt a function (From: Andrea Salomoni <email@hidden>)
 >Re: How to interrupt a function (From: Colin Barrett <email@hidden>)

  • Prev by Date: Re: How to interrupt a function
  • Next by Date: Re: How to interrupt a function
  • Previous by thread: Re: How to interrupt a function
  • Next by thread: Re: How to interrupt a function
  • Index(es):
    • Date
    • Thread