NSTask
来源:互联网 发布:域名代理平台 编辑:程序博客网 时间:2024/06/05 18:05
//// NSTask.h// ipacracker//// Created by obaby on 14-2-10.//// #ifndef ipacracker_NSTask_h#define ipacracker_NSTask_h /*NSTask.h Copyright (c) 1996-2007, Apple Inc. All rights reserved. */ #import <foundation /NSObject.h> @class NSString, NSArray, NSDictionary; @interface NSTask : NSObject // Create an NSTask which can be run at a later time// An NSTask can only be run once. Subsequent attempts to// run an NSTask will raise.// Upon task death a notification will be sent// { Name = NSTaskDidTerminateNotification; object = task; }// - (id)init; // set parameters// these methods can only be done before a launch- (void)setLaunchPath:(NSString *)path;- (void)setArguments:(NSArray *)arguments;- (void)setEnvironment:(NSDictionary *)dict;// if not set, use current- (void)setCurrentDirectoryPath:(NSString *)path;// if not set, use current // set standard I/O channels; may be either an NSFileHandle or an NSPipe- (void)setStandardInput:(id)input;- (void)setStandardOutput:(id)output;- (void)setStandardError:(id)error; // get parameters- (NSString *)launchPath;- (NSArray *)arguments;- (NSDictionary *)environment;- (NSString *)currentDirectoryPath; // get standard I/O channels; could be either an NSFileHandle or an NSPipe- (id)standardInput;- (id)standardOutput;- (id)standardError; // actions- (void)launch; - (void)interrupt; // Not always possible. Sends SIGINT.- (void)terminate; // Not always possible. Sends SIGTERM. - (BOOL)suspend;- (BOOL)resume; // status- (int)processIdentifier;- (BOOL)isRunning; - (int)terminationStatus; @end @interface NSTask (NSTaskConveniences) + (NSTask *)launchedTaskWithLaunchPath:(NSString *)path arguments:(NSArray *)arguments;// convenience; create and launch - (void)waitUntilExit;// poll the runLoop in defaultMode until task completes @end FOUNDATION_EXPORT NSString * const NSTaskDidTerminateNotification; #endif</foundation>//// main.cpp// NSTask//// Created by obaby on 14-2-27.// Copyright (c) 2014年 __MyCompanyName__. All rights reserved.// #include <iostream>#include "NSTask.h"#include <coredata /CoreData.h> void PingTest(); void PingTest(){ NSTask *task; task = [[NSTask alloc ]init]; [task setLaunchPath:@"/usr/bin/ping"]; NSLog(@"This is NSTask with ping command......\n"); NSArray *arguments; arguments = [NSArray arrayWithObjects:@"www.h4ck.org.cn", nil]; [task setArguments:arguments]; NSPipe *pipe; pipe = [NSPipe pipe]; [task setStandardOutput:pipe]; NSFileHandle *file; file = [pipe fileHandleForReading]; [task launch]; NSData *data; data = [file readDataToEndOfFile]; NSString *string; string = [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding]; NSLog(@"%@",string);} int main (int argc, const char * argv[]){ // insert code here... PingTest(); //std::cout < < "Hello, World!\n"; return 0;}
0 0
- NSTask
- NSTask Class
- nstimer,nsrunloop,nsthread,nstask
- 使用NSTask 挂载dmg 文件
- 通过NSTask用Cocoa执行perl脚本
- 通过NSTask用Cocoa执行perl脚本
- Launching executable with NSTask - Sandboxing problems?
- 通过NSTask用Cocoa执行perl脚本
- 关于NSTask使用的一些心得体会
- NSTask Tutorial for Mac OS X
- NSTask 在实际工程中的使用
- NSTimer、 NSTask、 NSThread 和 NSRunloop 之间的区别:
- NSTAsk的用法:Cocoa 调用外部可执行程序。
- 教程:通过NSTask用Cocoa执行perl脚本
- NSTimer、 NSTask、 NSThread 和 NSRunloop 之间的区别
- NSTimer、 NSTask、 NSThread 和 NSRunloop 之间的区别
- NSTimer、 NSTask、 NSThread 和 NSRunloop 之间的区别:
- Launch an NSTask and bring it to front
- 引用fwpsk.h 异常解决方式
- 在V小被v
- 目录与文件之权限意义
- 做网站需要考虑的事情
- Add Binary
- NSTask
- C++的多态
- maya api和mel 关系
- 阿朱看在线教育
- 润乾报表开发时候注意的小问题
- linux 正则使用
- java 获取当前年份、月份、日期,当月第一天和最后一天
- 对于各种报错的解决方案
- 开源集锦(一)(自定义控件)