当我想连接到我的服务器这样的时候
ssh -a username@my-server.de -p 22
Run Code Online (Sandbox Code Playgroud)
它给了我两个错误消息:
PTY allocation request failed on channel 0
shell request failed on channel 0
Run Code Online (Sandbox Code Playgroud)
当我使用参数时-T,第一个错误消息消失了.但是如何修复第二个呢?我无法连接.对于其他服务器,我可以毫无问题地连接.
我在MAC OS 10.9上参数-v显示了这个调试输出:
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to xxx.your-server.de [188.40.3.15] port 22.
debug1: Connection established.
debug1: identity file /Users/xxx/.ssh/id_rsa type -1
debug1: identity file /Users/xxx/.ssh/id_rsa-cert type -1
debug1: identity file /Users/xxx/.ssh/id_dsa type -1
debug1: identity file /Users/xxx/.ssh/id_dsa-cert type …Run Code Online (Sandbox Code Playgroud) 我试着调用fileManager.createFileAtPath-method,但总是失败.我的变量success总是如此false.我在这里查看了一些类似的帖子,但完全不符合我的需求.这是我的代码:
pListPath = NSURL(fileURLWithPath: String(reportsPath)).URLByAppendingPathComponent("myReports.plist", isDirectory: false)
let data: NSData = NSData()
var isDir: ObjCBool = false
if fileManager.fileExistsAtPath(String(pListPath), isDirectory: &isDir)
{
print("File already exists")
}
else
{
let success = fileManager.createFileAtPath(String(pListPath), contents: data, attributes: nil)
print("Was file created?: \(success)")
print("plistPath: \(pListPath)")
}
Run Code Online (Sandbox Code Playgroud)
这是我试图解决这个问题的方法:
我试着用这个方法
let success = NSFileManager.defaultManager().createFileAtPath(String(pListPath), contents: data, attributes: nil)
Run Code Online (Sandbox Code Playgroud)
并且
let success = data.writeToFile(String(pListPath), atomically: true)
Run Code Online (Sandbox Code Playgroud)
但没有任何作用.success永远false.我也尝试给它一个文字字符串作为路径,设置contents为nil,我甚至改变了目录权限,我想把它放到777,但注意到工作.success总是假的.我希望你能帮我解决这个问题.任何帮助都非常感谢.谢谢
我的macOS应用程序使用的是一个简单功能,该功能应建立与服务器的连接,但是无论我如何尝试,我都无法使其正常运行。
我从其他网站复制了一个示例,但是它不起作用。我还观看了其他示例,但其中大多数都非常古老且过时。这是我的代码:
func connect(){
// Set up the URL request
let todoEndpoint: String = "https://www.google.com"
guard let url = URL(string: todoEndpoint) else {
print("Error: cannot create URL")
return
}
let urlRequest = URLRequest(url: url)
// set up the session
let config = URLSessionConfiguration.default
let session = URLSession(configuration: config)
// make the request
let task = session.dataTask(with: urlRequest, completionHandler: { (data, response, error) in
// do stuff with response, data & error here
print(error as Any)
print(response as Any)
})
task.resume() …Run Code Online (Sandbox Code Playgroud) 我正在使用一个简单的UIView动画,并为其添加了一个渐变层。我想增加视图的宽度和放置在视图上的图层,但我得到的只是视图增加了它的宽度而不是图层。
示例:假设我有一个UIViewwithheight = width = 50
我通过将宽度设置为动画来设置它:width += 50。这个动画正在运行。如果我对图层做同样的事情,就会发生注意。该层不会增加其宽度。我尝试了一些方法来解决此问题(请参阅代码中的注释),但没有任何效果。
这是我的代码
func performNextTitleAnimation() {
let overlayViewHeight = overlayView.frame.size.height
let overlayViewWidth = overlayView.frame.size.width
let animationHeight: CGFloat = 48
let overlayViewHalfHeight = (overlayViewHeight) / 2
swipeAnimation = UIView(frame: CGRect(x: 0, y: overlayViewHalfHeight - (animationHeight/2), width: 48, height: animationHeight))
swipeAnimation.backgroundColor = .gray
swipeAnimation.layer.cornerRadius = swipeAnimation.frame.size.height / 2
gradientLayer.frame = swipeAnimation.bounds
overlayView.addSubview(swipeAnimation)
swipeAnimation.layer.addSublayer(gradientLayer)
UIView.animate(withDuration: 1.2, delay: 0, options: [.repeat], animations: {
self.gradientLayer.cornerRadius = 24
self.swipeAnimation.frame.size.width += 50
//Things …Run Code Online (Sandbox Code Playgroud)