Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/43.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 越狱iOS:NSTASKIDTerminateNotification无法启动选择器_Iphone_Jailbreak_Nstask_Nsnotification - Fatal编程技术网

Iphone 越狱iOS:NSTASKIDTerminateNotification无法启动选择器

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

我似乎遇到了和这里一样的问题:

下面是我通过NSNotification(如上所述)获得的信息,但是没有出现
任务结束:
警报。正如我在调试器中看到的那样,脚本肯定是在运行的

-(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];