如何制作应用程序以显示在终端中使用 w 命令登录到计算机的所有用户?
我制作了 Beta 版应用程序,但它禁用了沙盒 [它显示了用户],但它没有启用沙盒 [它说没有用户登录]。代码是:
NSTask *task = [NSTask new];
[task setLaunchPath:@"/usr/bin/w"];
NSPipe *output = [NSPipe pipe];
[task setStandardInput:[NSPipe pipe]];
[task setStandardOutput: output];
[task launch];
NSFileHandle * read = [output fileHandleForReading];
NSData * dataRead = [read readDataToEndOfFile];
NSString *result = [[NSString alloc] initWithData:dataRead encoding:NSUTF8StringEncoding];
[TView setString: result];