我正在用Swift编写命令行工具,我在shell中显示颜色时遇到问题.我正在使用以下代码:
println("\033[31;32mhey\033[39;39m")
Run Code Online (Sandbox Code Playgroud)
甚至
NSFileHandle.fileHandleWithStandardOutput().writeData("\033[31;32mhey\033[39;39m".dataUsingEncoding(NSASCIIStringEncoding, allowLossyConversion: true)!)
Run Code Online (Sandbox Code Playgroud)
当我在php中使用一个简单的echo(文本显示为绿色)时,它有效,但是有一个原因它在Swift命令行工具中不起作用吗?
谢谢!
我正在开发一个创建内容并将其发送到现有后端的应用程序.内容是标题,图片和位置.没有什么花哨.
后端有点复杂,所以这就是我要做的事情:
我已经使用了几个NSOperation子类来完成这项工作,但我并不为我的代码感到自豪,这里有一个示例.
NSOperation *process = [NSBlockOperation blockOperationWithBlock:^{
// Process image before upload
}];
NSOperation *filename = [[NSInvocationOperation alloc] initWithTarget: self selector: @selector(generateFilename) object: nil];
NSOperation *generateEntry = [[NSInvocationOperation alloc] initWithTarget: self selector: @selector(createEntry) object: nil];
NSOperation *uploadImage = [[NSInvocationOperation alloc] initWithTarget: self selector: @selector(uploadImageToCreatedEntry) object: nil];
NSOperation *refresh = [NSBlockOperation blockOperationWithBlock:^{
// Update UI
[SVProgressHUD showSuccessWithStatus: NSLocalizedString(@"Success!", @"Success HUD message")];
}];
[refresh addDependency: uploadImage];
[uploadImage addDependency: generateEntry];
[generateEntry addDependency: filename];
[generateEntry addDependency: process];
[[NSOperationQueue …Run Code Online (Sandbox Code Playgroud) colors ×1
command ×1
ios ×1
lego ×1
nsoperation ×1
objective-c ×1
parsing ×1
swift ×1
xterm ×1