gpt4 book ai didi

nsstring - NSURLConnection,Swift 中远程服务器的授权

转载 作者:行者123 更新时间:2023-11-30 10:23:15 25 4
gpt4 key购买 nike

这是示例代码。我的字符串有错误:

var theReply = String.stringWithBytes(GETReply.bytes,长度:GETReply.length,编码:NSASCIIStringEncoding)

错误:

找不到接受所提供参数的“_conversion”重载

出了什么问题?

@IBAction func loginButton(sender: AnyObject) {

if !loginL.text.isEmpty || !passL.text.isEmpty {
var request:NSMutableURLRequest = NSMutableURLRequest()
var login = loginL.text.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)
var pass = passL.text.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)
var stringURL = "http://nakhimov.info/iosdev/user.php?t=1&l=\(login)&p=\(pass)"
NSLog("URL string for login: \(stringURL)")

var webURL = stringURL.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)
request.URL = NSURL.URLWithString(webURL)
request.HTTPMethod = "GET"
request.setValue("application/json;charset=UTF-8", forHTTPHeaderField: "Content-Type")

var responce:NSURLResponse?
let GETReply:NSData = NSURLConnection.sendSynchronousRequest(request, returningResponse: &responce, error: nil)
var theReply = String.stringWithBytes(GETReply.bytes, length: GETReply.length, encoding: NSASCIIStringEncoding)

var wrong = "ERROR"

if theReply == wrong {
myAlertShow("ERROR!", message: "Login or password is invalid")
}
else {
self.performSegueWithIdentifier("closeZoneSegue", sender: self)
}
}

resetToDefaults()
}

最佳答案

解决了! :-)

var theReply = NSString(bytes: GETReply.bytes, length: GETReply.length, encoding: NSASCIIStringEncoding)

关于nsstring - NSURLConnection,Swift 中远程服务器的授权,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24529934/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com