Iphone 越狱iOS:NSTASKIDTerminateNotification无法启动选择器
我似乎遇到了和这里一样的问题: 下面是我通过NSNotification(如上所述)获得的信息,但是没有出现Iphone 越狱iOS:NSTASKIDTerminateNotification无法启动选择器,iphone,jailbreak,nstask,nsnotification,Iphone,Jailbreak,Nstask,Nsnotification,我似乎遇到了和这里一样的问题: 下面是我通过NSNotification(如上所述)获得的信息,但是没有出现任务结束:警报。正如我在调试器中看到的那样,脚本肯定是在运行的 -(IBAction) supported { stask = [[NSTask alloc] init]; [stask setLaunchPath:@"/bin/bash"]; NSString *script; script = [[[NSBundle mainBundle] bundle
任务结束:
警报。正如我在调试器中看到的那样,脚本肯定是在运行的
-(IBAction) supported {
stask = [[NSTask alloc] init];
[stask setLaunchPath:@"/bin/bash"];
NSString *script;
script = [[[NSBundle mainBundle] bundlePath] stringByAppendingString:@"/apps.sh"];
NSArray *sargs = [NSArray arrayWithObjects:script, @"-txt", nil];
[stask setArguments: sargs];
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(taskEnded:)
name: NSTaskDidTerminateNotification
object: nil];
[stask launch];
}
- (void)taskEnded:(NSNotification *)notification {
if (stask == [[notification object] terminationStatus]) {
NSString *apps;
apps = [NSString stringWithContentsOfFile:@"/var/mobile/supported.txt" encoding:NSUTF8StringEncoding error:nil];
NSFileManager *fm = [NSFileManager defaultManager];
if ([fm fileExistsAtPath:apps]) {
UIAlertView *supported = [[UIAlertView alloc] initWithTitle:@"Apps" message:apps delegate:self cancelButtonTitle:@"Ok!" otherButtonTitles:nil];
[supported show];
[supported release];
} else {
UIAlertView *supported = [[UIAlertView alloc] initWithTitle:@"Apps" message:@"Error generating list." delegate:self cancelButtonTitle:@"Ok!" otherButtonTitles:nil];
[supported show];
[supported release];
}
} else {
NSLog(@"Task failed.");
}
}
试一试
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(taskEnded:)
name: NSTaskDidTerminateNotification
object: stask];