Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NSLog(@"myString is :%@", myString);
- int processID = [myString intValue];
- NSTask *task;
- task = [[NSTask alloc] init];
- [task setLaunchPath: @"/bin/ps"];
- arguments = [NSArray arrayWithObjects: @"aux", [NSString stringWithFormat:@"%i", processID],nil];
- [task setArguments: arguments];
- NSPipe *pipe;
- pipe = [NSPipe pipe];
- //[task setStandardOutput: 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);
- NSArray *lines= [string componentsSeparatedByString:@"n"];
- NSString *lastline = [lines objectAtIndex:[lines count]-2];
- // NSLog(@"%@",lastline);
- lines2= [lastline componentsSeparatedByString:@" "];
- NSLog(@"%@",lines2);
- for (int i=0; i<[lines2 count]; i++) {
- if([[lines2 objectAtIndex:i] isEqualToString:@""]){
- [lines2 removeObjectAtIndex:i];
- }
- }
- for (int i=0; i<[lines2 count]; i++) {
- if([[lines2 objectAtIndex:i] isEqualToString:@""]){
- [lines2 removeObjectAtIndex:i];
- }
- }
- for (int i=0; i<[lines2 count]; i++) {
- if([[lines2 objectAtIndex:7] isEqualToString:@"Ss"]){
- [[lines2 objectAtIndex:0] replaceObjectAtIndex:7 withObject:@"SS (Running)"];
- }
- }
- - (NSArray *)componentsSeparatedByString:(NSString *)separator
- [[lines2 objectAtIndex:0] replaceObjectAtIndex:7 withObject:@"SS (Running)"];
- ^^^^^^^^^^^^^^^^^^^^^^^^ This is wrong
- NSMutableArray * myMutableArray = [NSMutableArray arrayWithArray:lines2];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement