我正在尝试将图像上传到存储桶S3 AWS,我正在使用以下代码.但我是否使用它上传到存储在变量或imageView.image中的图像?
let ext = "jpg"
let imageURL = NSBundle.mainBundle().URLForResource("imagename", withExtension: ext)
print("imageURL:\(imageURL)")
let uploadRequest = AWSS3TransferManagerUploadRequest()
uploadRequest.body = imageURL
uploadRequest.key = NSProcessInfo.processInfo().globallyUniqueString + "." + ext
uploadRequest.bucket = S3BucketName
uploadRequest.contentType = "image/" + ext
let transferManager = AWSS3TransferManager.defaultS3TransferManager()
transferManager.upload(uploadRequest).continueWithBlock { (task) -> AnyObject! in
if let error = task.error {
print("Upload failed ? (\(error))")
}
if let exception = task.exception {
print("Upload failed ? (\(exception))")
}
if task.result != nil {
let s3URL = NSURL(string: "http://s3.amazonaws.com/\(self.S3BucketName)/\(uploadRequest.key!)")!
print("Uploaded to:\n\(s3URL)")
} …Run Code Online (Sandbox Code Playgroud) 我正在尝试从服务器获取 json 并对其进行反序列化,但我尝试使用未转义的控制字符进行探测。我的代码如下...
let urlFinal = "http://000.0000.000.000:8080"
let jsonUrl = urlFinal
let session = NSURLSession.sharedSession()
let shotsUrl = NSURL(string: jsonUrl)
let task = session.dataTaskWithURL(shotsUrl!) {data, response, error in
guard data != nil else {
falha()
return
}
//let json = JSON(data: data!)
//print(json["ServicoCliente"][0]["id"])
do {
let jsonData = try NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.MutableContainers )
let J = jsonData as! NSDictionary
print(jsonData)
let us = J["ServicoCliente"]
print(us)
dispatch_async(dispatch_get_main_queue(),{
sucesso()
});
} catch _ {
falha()
}
}
task.resume()
Run Code Online (Sandbox Code Playgroud)
我也使用 Alamofire 3.0 尝试过这个: …
我需要为我的tableview创建一个自定义标题.为此我创建了一个UITableViewHeaderFooterView类的类,但我无法在故事板上选择tableview的标题来设置类.如果它是一个静态表头,但它对动态表不可见.我该怎么做这个设置?
注意:我使用xcode 7.3.1
我正在尝试这样做,但是故事板:https: //github.com/jeantimex/ios-swift-collapsible-table-section
override func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let header = tableView.dequeueReusableHeaderFooterViewWithIdentifier("header") as! NovaListaTableViewHeader
header.titleLabel.text = sections[section].name
header.arrowLabel.text = ">"
header.setCollapsed(sections[section].collapsed)
header.section = section
header.delegate = self
return header
}
Run Code Online (Sandbox Code Playgroud)