alamofire

UIProgressView progress update very slow within AlamoFire (async) call

↘锁芯ラ 提交于 2019-12-04 15:11:04
Inside an AlamoFire get request I'm trying to update my progress bar. Like so: alamofireManager.request(.GET, urlPath, parameters: params).responseJSON{(request,response,JSON,error) in ...<code here>... dispatch_async(dispatch_get_main_queue(), { NSNotificationCenter.defaultCenter().postNotificationName(LoginVCHideSpinnerAndShowProgressBarName as String, object: self) }) ...<more code here>... } For some reasons this takes a few seconds to execute and if I use dispatch_sync instead the app just seems to get stuck at that point but the UI doesn't freeze up (the activity indicator spinner keeps

ios 8, Swift, receipt validation for IAP

喜夏-厌秋 提交于 2019-12-04 14:43:36
i'm desperately trying to validate a receipt for in-app in a futur IOS application written with Swift, IOS8.1 I'm using the Alamofire framework to compensate a bug in NSURLConnection for swift but still not having any return from the Apple Server. func checkReceipt(data:NSData) { let ITMS_PROD_VERIFY_RECEIPT_URL = "https://buy.itunes.apple.com/verifyReceipt" let ITMS_SANDBOX_VERIFY_RECEIPT_URL = "https://sandbox.itunes.apple.com/verifyReceipt" let base64String = self.base64forData(data) if base64String != nil { let decodedData = NSData(base64EncodedString: base64String!, options:

Swift 3- Update UI from main thread

假如想象 提交于 2019-12-04 14:38:55
I wanted to load data in background thread and update tableview/UI on main thread. Based on what's indicated here about threading, I was wondering if the code below is the way to go about it. I'm trying to load more data as user scrolls to a specific index and wanted to make sure the UI is not freezing due to threading. Thank you! func loadMore () { guard !self.reachedEndOfItems else { return } self.offset = self.offset! + 10 print("load more offset: \(self.offset)") var start = 0 var end = 0 isPullToRefresh = false let userCreds = UserDefaults.standard var getReqString = "" if userCreds.bool

Adding Cocoapods To Multiple Targets

China☆狼群 提交于 2019-12-04 13:12:19
I'm needing to add Alamofire to my main iOS app and the iOS Today Extention. With Alamofire just being in my iOS app target, it works great! But now, I'm trying to add Alamofire to my today extention. This is my Podfile # Uncomment the next line to define a global platform for your project # platform :ios, '9.0' target 'The Main iOS App' do # Comment the next line if you're not using Swift and don't want to use dynamic frameworks use_frameworks! pod 'Canvas' pod 'Firebase/Core’ pod 'Firebase/Messaging’ pod 'Alamofire', '~> 4.4' # Pods for The Main iOS App end target 'Today' do # Comment the

Create JSON Object from Class in Swift

微笑、不失礼 提交于 2019-12-04 11:39:55
I'm pretty new to iOS development and Swift (so please bear with me). I have a class object defined like this: class LocationPoint { var x: Double var y: Double var orientation: Double init(x: Double, y: Double, orientation: Double) { self.x = x self.y = y self.orientation = orientation } } In my delegate, I create an instance of the class and append it to an array (declared outside the delegate): var pt = LocationPoint(x: position.x, y: position.y, orientation: position.orientation) self.LocationPoints.append(pt) So far so good. I can show the array values in a textview object in my

Realm: Map JSON to Realm-Objects with Alamofire

荒凉一梦 提交于 2019-12-04 09:52:57
I would like to use Realm and Alamofire to map JSON to my database objects. Are there good tutorials out there? Realm offers built-in limited capabilities of mapping arbitrary JSON structures to RLMObjects . But there are some good third-party libraries, which could assist you with your use-case. You might want to checkout these: Realm-JSON (Objective-C), which offers a declarative, Mantle like way of defining your mapping ObjectMapper (Swift), which offers Realm and Alamofire support 来源: https://stackoverflow.com/questions/33479733/realm-map-json-to-realm-objects-with-alamofire

Alamofire Request error only on GET requests

本小妞迷上赌 提交于 2019-12-04 09:29:40
I'm working on transferring my project from AFNetworking to Alamofire. Really like the project. POST requests work just fine, however, I'm receiving this error when attempting to make a GET request. Here's some example code: class func listCloudCredntials(onlyNew onlyNew: Bool = true, includePending: Bool = true) -> Request { let parameters: [String: AnyObject] = includePending ? ["include_pending": "true"] : [:] let urlString = "https://myapp-staging.herokuapp.com/api/1/credntials" let token = SSKeychain.storedToken() let headers: [String: String] = ["Authorization": "Bearer \(token)"] return

Alamofire with custom parameter encoding for swift application

十年热恋 提交于 2019-12-04 09:20:12
I have to call some methods from the soap web service in my swift application, so I think I should use custom parameter encoding, but when I create closure for this encoding it seems never to be called. Am I doing something wrong? Here is my code: let custom: (URLRequestConvertible, [String: AnyObject]?) -> (NSURLRequest, NSError?) = { (URLRequest, parameters) in let mutableURLRequest = URLRequest.URLRequest.mutableCopy() as NSMutableURLRequest mutableURLRequest.setValue("text/xml; charset=utf-8", forHTTPHeaderField: "Content-Type") mutableURLRequest.HTTPBody = body return (mutableURLRequest,

how to parsing Json with SwiftyJson from woocommerce api?

蓝咒 提交于 2019-12-04 06:26:58
问题 I want to parse JSON using alamofire and swiftyjson I try get JSON(value) like this let headers: HTTPHeaders = [ "Authorization": "Basic Y2tfZTA1ZGNmMDkwNTNmODEyMGQwYTMyOGI4YzJkY2QzOTY5MmE5ZDAyNzpjc18zYzZiYWY2NTM0NDhkNDM4ZDM1ZDNmNDY5Nzg5ZGM2Y2VhZGRiZjNl", "Accept": "application/json" ] Alamofire.request("https://woo.demoapp.xyz/wp-json/wc/v2/products?category=15", headers: headers).responseJSON { response in debugPrint(response) if let json = response.result.value { print("JSON: \(json)") } }

Alamofire Asynchronous requests happening out of order in for loop

梦想与她 提交于 2019-12-04 06:12:32
问题 I'm having this strange issue with Alamofire asynchronous requests in Swift. Here is the pseudocode for what I am trying to do. for each email: GET request to grab first_name for email add first_name to an array The issue is that the end array is out of order. When it should be [User 3, User 1, User 2] it is instead [User 3, User 2, User 1]. I've tested my backend funtions with Postman and everything works so am confused as to what exactly is the problem. Any insight into what might be