Exit runloop and restart application - MacRumors Forums
Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jun 29, 2013, 02:02 AM   #1
mehdies
macrumors member
 
Join Date: Jun 2012
Exit runloop and restart application

I have a runloop that loop a method.I want to exit runloop and restart application in certain cases.how do that?

my runloop source :

Code:
 NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:0.2 target:object selector:@selector(objectMethod) userInfo:nil repeats:YES];
            [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode];
            [[NSRunLoop currentRunLoop] run];
mehdies is offline   0 Reply With Quote
Old Jun 29, 2013, 12:14 PM   #2
gnasher729
macrumors G5
 
gnasher729's Avatar
 
Join Date: Nov 2005
Quote:
Originally Posted by mehdies View Post
I have a runloop that loop a method.I want to exit runloop and restart application in certain cases.how do that?

my runloop source :

Code:
 NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:0.2 target:object selector:@selector(objectMethod) userInfo:nil repeats:YES];
            [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode];
            [[NSRunLoop currentRunLoop] run];
Think about what scheduledTimerWithTimeInterval: does.

Apart from that, your request is really weird and it seems you are asking for help to shoot yourself in the foot. What do you actually try to achieve?
gnasher729 is offline   1 Reply With Quote
Old Jun 29, 2013, 12:31 PM   #3
cqexbesd
macrumors member
 
Join Date: Jun 2009
Quote:
Originally Posted by mehdies View Post
I have a runloop that loop a method.I want to exit runloop and restart application in certain cases.how do that?
If you really want to restart from scratch you could just re-exec yourself or maybe setjmp/longjmp?
cqexbesd is offline   1 Reply With Quote
Old Jun 29, 2013, 10:48 PM   #4
mehdies
Thread Starter
macrumors member
 
Join Date: Jun 2012
Quote:
Originally Posted by gnasher729 View Post
Think about what scheduledTimerWithTimeInterval: does.

Apart from that, your request is really weird and it seems you are asking for help to shoot yourself in the foot. What do you actually try to achieve?
I use this code snippet in application source code :


Code:
NSDictionary *activeApp = [[NSWorkspace sharedWorkspace] activeApplication];
            appName = (NSString*)[activeApp objectForKey:@"NSApplicationName"];
i use this code for getting active(focused application's) name.application works good but when i logout and login again appName variable got null value!

* this code snippet exist in the runlooped method.

I find out when restart the daemon,it's works well! first i unload the daemon and load again with blow commands :


Code:
launchctl unload /Library/LaunchDaemons/daemon.plist

Code:
launchctl load /Library/LaunchDaemons/daemon.plist
I have another daemon(second daemon) like mentioned daemon when first daemon got null second daemon restart first daemon.but not works!

i use mentioned commands in second daemon like below :


Code:
 system("launchctl unload /Library/LaunchDaemons/daemon.plist");

Code:
  system("/bin/launchctl load /Library/LaunchDaemons/daemon.plist");

but these commands can't restart daemon.when i remove load command unload command works.

----------

Quote:
Originally Posted by cqexbesd View Post
If you really want to restart from scratch you could just re-exec yourself or maybe setjmp/longjmp?
Yes,i want to relaunch application again and exit() first process of application.
mehdies is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
GCD, runloop & background app refresh ChristianJapan iPhone/iPad Programming 0 Mar 19, 2014 07:20 AM
iPhone: Can't Exit Out Of Safe Mode? jennn Jailbreaks and iOS Hacks 4 Nov 13, 2013 03:25 PM
pia_tray application is cancelling restart Kanunu Mac OS X 10.7 Lion 2 Aug 6, 2013 10:40 AM
iPhone: Exit Safe Mode Homer3 Jailbreaks and iOS Hacks 1 Feb 4, 2013 01:37 PM
No exit numbers in new maps? Craiger iOS 6 1 Sep 21, 2012 10:48 AM

Forum Jump

All times are GMT -5. The time now is 12:05 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC