嗨,我是 swift 的新手,我遇到了问题,我用 post 方法向服务器发出了一个请求,我得到了良好的 Json 响应,之后我又用 get 方法发出了另一个请求,但出现了这个错误。
错误: responseSerializationFailed(Alamofire.AFError.ResponseSerializationFailureReason.jsonSerializationFailed(Error Domain=NSCocoaErrorDomain Code=3840 “字符 0 周围的值无效。” UserInfo={NSDebugDescription=字符 0 周围的值无效。})
请求参数:
static func getInformationFromConfig(token: String, config: String, section : String, option: String) -> [String:Any] {
let getInformationFromConfigparam: [String : Any] = ["jsonrpc": "2.0",
"id": 1,
"method": "call",
"params": [ token, "uci", "get", [ "config": config, "section": section, "option": option]]
]
return getInformationFromConfigparam
}
public func device(token: String, loginCompletion: @escaping (Any) -> ()) {
let deviceinfo = JsonRequests.getInformationFromConfig(token: token, config: "wireless", section: …Run Code Online (Sandbox Code Playgroud) 我有谷歌地图标记的问题,我想把标记触摸,但我不知道如何处理它我尝试了一些方法,但它没有工作,没有任何反应,然后我触摸地图.新闻识别似乎有问题.
更新:
class MainMapController: UIViewController, CLLocationManagerDelegate {
@IBOutlet weak var viewMap: GMSMapView!
var makers: [GMSMarker] = []
var locationManager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
initializeTheLocationManager()
self.viewMap.isMyLocationEnabled = true
let longPressRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(handleLongPress))
self.viewMap.addGestureRecognizer(longPressRecognizer)
}
func handleLongPress(recognizer: UILongPressGestureRecognizer)
{
if (recognizer.state == UIGestureRecognizerState.began)
{
let longPressPoint = recognizer.location(in: self.viewMap);
let coordinate = viewMap.projection.coordinate(for: longPressPoint )
let marker = GMSMarker(position: coordinate)
marker.opacity = 0.6
marker.title = "Current Location"
marker.snippet = ""
marker.map = viewMap
makers.append(marker)
}
} …Run Code Online (Sandbox Code Playgroud)