alamofire

Swift behaves differently on debug and release mode

一个人想着一个人 提交于 2019-12-05 15:57:44
问题 Not sure if that's an issue with Swift, XCode or Alamofire but I recognized strange behavior on different places within my mixed Swift/Objc app . It only happens in parts which are written in Swift and use closures/networking. Here's an example code where it happens: Alamofire.request(.DELETE, "http://someUrl.com/user", parameters: nil) .response { (request, response, data, error) in // some cleanup code and an alert } When I run my app in Debug mode on my iPhone then it all just works , the

Alamofire not handling Authentication challenge

假如想象 提交于 2019-12-05 14:30:50
Utilizing Alamofire, Im noticing that the code below isn't being hit with a breakpoint. I make a connection, and I get the following error: (Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo=0x1741b3f60 {_kCFStreamErrorCodeKey=-9806, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, NSUnderlyingError=0x17484b8e0 "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error -1200.)", NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be

iOS - Cannot call value of non-function type 'NSProgress'

戏子无情 提交于 2019-12-05 14:08:03
I'm trying to download a file using Alamofire, with progress. But I get this error at the progress line. Cannot call value of non-function type 'NSProgress' What's the problem? All the examples I've seen, namely the official one , do the exact same thing! Alamofire.download(.GET, nsurl!.absoluteString, destination: { (temporaryURL, response) in return filepath }) .progress { (bytesRead, totalBytesRead, totalBytesExpectedToRead) in // <------ ERROR HERE dispatch_async(dispatch_get_main_queue(), { self.progressBar?.progress = totalBytesRead / totalBytesExpectedToRead }) } .response { (request,

Showing JSON data on TableView using SwiftyJSON and Alamofire

守給你的承諾、 提交于 2019-12-05 10:40:51
I want to show the JSON data grabbed from a server on a Table View. The problem is, I can't get it to show up on it. I have tried several different methods and searched a lot to find a solution, but I can't. My code (all of it) is shown below and I hope somebody can help me out. Thanks in advance. import UIKit import Alamofire import SwiftyJSON class MasterViewController: UITableViewController { var tableTitle = [String]() var tableBody = [String]() override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. getJSON() } func

Alamofire Swift 2 - cannot submit for beta testing (Xcode 7 GM)

人走茶凉 提交于 2019-12-05 10:21:55
I have followed the instructions on installing the swift2 branch of Alamofire with cocoa pods. The app works well in the simulator, however, when I archive it for submission with Xcode 7 GM I receive an email with an error: "The bundle contains an invalid implementation of Swift. The app may have been built or signed with non-compliant or pre-release tools" This issue definitely relates to the framework as without it I am able to submit for beta testing with the same version of Xcode. I have tried turning bit code OFF in the build settings for Alamofire but it does not help. Does anyone know

Alamofire returns wrong encoding

纵饮孤独 提交于 2019-12-05 10:13:01
I`m using Alamofire.request(.GET, "http://") .responseString { _, _, string, _ in println(string) } to make get-request. Response contains сyrillic symbols and in responseString they looks like this (top-right): How should I fix encoding? You can use NSUTF8StringEncoding with Alamofire's responseString method: Alamofire.request(.GET, "http://my1test.ru/applejesus.php?task=getCategory&categoryNumber=1") .responseString(encoding: NSUTF8StringEncoding) { (request, response, string, error) -> Void in if let result = string { println(result) } } Result: picture{ http://ipic.su/img/img7/fs

Alamofire 4, Swift 3 and building a json body

霸气de小男生 提交于 2019-12-05 08:18:34
{"title":"exampleTitle","hashTags":[{"name":"tag1"},{"name":"tag2"}],"uploadFiles": [{"fileBytes":"seriesOfBytes\n","filename":"upload.txt"}]} That is my desired body I want to send to the backend. I'm using Swift 3.0 and Alamofire 4 and i have multiple questions. first , How do i correctly create a body which contains values and arrays of values? My approach is: let para:NSMutableDictionary = NSMutableDictionary() para.setValue("exampleTitle", forKey: "title") let jsonData = try! JSONSerialization.data(withJSONObject: para, options: .init(rawValue: 0)) let jsonString = NSString(data: jsonData

swift 2.1 alamofire timeout method

十年热恋 提交于 2019-12-05 07:10:59
i have question about alamofire timeout methods, first of all , my english may not be good enough to let you guys to understand what i said... but i will tired to explain my question in my project, i used alamofire , for some reason , i need to make sure my app working of poor connection area. so i am thinking using timeout method. i saw there are some people said , use Solution 1: let configuration = NSURLSessionConfiguration.defaultSessionConfiguration() configuration.timeoutIntervalForRequest = 2 // seconds self.alamofireManager = Alamofire.Manager(configuration: configuration) self

Type does not conform to protocol 'URLRequestConvertible' with Alamofire

六眼飞鱼酱① 提交于 2019-12-05 06:42:51
Here's the code: enum Router: URLRequestConvertible { //Error: Type 'Five100px.Router' does not conform to protocol 'URLRequestConvertible' static let baseURLString = "https://api.500px.com/v1" static let consumerKey = "MY_KEY" case PopularPhotos(Int) case PhotoInfo(Int, ImageSize) case Comments(Int, Int) var URLRequest: NSURLRequest { let (path, parameters) : (String, [String: AnyObject]) = { switch self { case .PopularPhotos(let page): let params = ["consumer_key": Router.consumerKey, "page": "\(page)", "feature": "popular", "rpp": "50", "include_store": "store_download", "include_status":

Alamofire and Objectmapper adding data to tableview

社会主义新天地 提交于 2019-12-05 06:40:57
问题 [ { "userId": 1, "id": 1, "title": "xxxxx", "body": "yyyyy" }, { My json data is like that and I'm using alamofire for loading data and objectmapper for mapping. I create a swift file for mapping like that: import Foundation import ObjectMapper class TrainSchedules: Mappable { var mySchedules: [Schedules] required init?(map: Map) { mySchedules = [] } func mapping(map: Map) { mySchedules <- map["schedule"] } } class Schedules: Mappable { var userId: String var id: String var title: String var