afnetworking-2,alamofire , AFNetworkActivityManager for AlamoFire?


AFNetworkActivityManager for AlamoFire?

Question:

Tag: afnetworking-2,alamofire

AFNetworking allows one to do:

[[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES];

But I have not figured out how to do this with the Swift AlamoFire equivalent. I've searched the source for some of the same terms, but don't see anything yet.

(I'm learning Swift, so be gentle).


Answer:

Your assessment is correct @travis. There is currently no support for such an activity indicator in the latest version of Alamofire. If you need this functionality, you'll have to build it out on your own at the moment. With that said, I know the project is always accepting PRs having submitted many myself. 👍ðŸ


Related:


iOS - Asynchronous requests and UI interactions


ios,swift,asynchronous,uicollectionview,alamofire
I have a page that uses Alamofire to retrieve images from Google Image Search API and display them inside a collectionView. Everything works, but when the request is still loading I can't interact at all with the UI, whether it's clicking a button or scrolling the collectionView. Is this normal...

What are Embedded Binaries in Xcode?


xcode,xcode6,alamofire
I'm using Alamofire in a Swift project, and part of their manual installation instructions are to add Alamofire under Embedded Binaries in the General tab for my application target. What are Embedded Binaries?...

How to create an API like Alamofire does in Swift?


ios,swift,alamofire
In the Alamofire.swift file the main API functions are not nested within a class or struct: import Foundation ... public func request(method: Method, URLString: URLStringConvertible, parameters: [String: AnyObject]? = nil, encoding: ParameterEncoding = .URL) -> Request { return Manager.sharedInstance.request(method, URLString, parameters: parameters, encoding: encoding) } yet they are able to...

Compiler error in custom Alamofire response function


ios,swift,alamofire
I'm attempting to implement a generic responseObject function for Alamofire using Argo. Unfortunately I'm getting a persistent compiler error: error: missing argument for parameter #2 in call APIManager.manager.request(APIRouter.Login(username: usernameTextField.text, password: passwordTextField.text)).responseObject { (object, error) -> Void in I understand this error to usually mean something about tuples, so I'm guessing...

Alamofire “installation” not working (red text in Embedded Binaries)


ios,xcode,swift,xcode6,alamofire
I am trying to add Alamofire to my xcode v6.3.2 project but it's not working for me. I followed all the steps in the readme from the github repo but when I select the framework to add as an "Embedded Binary" it shows with red text and is not available...

error calling functions in swift with a JSON response


ios,json,swift,alamofire
Could anyone else help me to know which is the way to call functions in swift, receiving a JSON collection response? I'm calling ApiClient().getList() function in viewController.swift,this function calls to my API and receives a JSON response in apiClient.swift and finally I would like to assign this JSON response to...

Handling XML data with Alamofire in Swift


ios,xml,swift,alamofire
I started to use cocoapods with my current ios project. I need to use SOAP to get content with easy way for my ios project. I have googled it and Alamofire pod is great for me. Because I am using Swift programming language. I have inited easily this pod. But...

AFNetworking sending URL as post parameter


ios,objective-c,afnetworking-2,nsurlrequest
I am calling an API in which I am sending a URL link as a post parameter with it. But while converting it into JSON data using NSData* jsonData = [NSJSONSerialization dataWithJSONObject:lParameters options:NSJSONWritingPrettyPrinted error:&error]; it adds extra '\' character into the link. and when I log that data string, it...

NSMutableURLRequest setValue:forHTTPHeaderField xcode 6.2 not working for “application/json; charset=utf-8”


ios,xcode,utf-8,http-headers,alamofire
I am developing and app, with Alamofire, in Xcode 6.2, and by default Alamofire has this for .JSON encoding: mutableURLRequest.setValue("application/json", forHTTPHeaderField: "Content-Type") However, I need value to be like this: mutableURLRequest.setValue("application/json; charset=utf-8", forHTTPHeaderField: "Content-Type") The problem is that after this line, if I print allHTTPHeaderFields, I have: (lldb) po mutableURLRequest.allHTTPHeaderFields!.description...

AFNetworkActivityManager for AlamoFire?


afnetworking-2,alamofire
AFNetworking allows one to do: [[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES]; But I have not figured out how to do this with the Swift AlamoFire equivalent. I've searched the source for some of the same terms, but don't see anything yet. (I'm learning Swift, so be gentle)....

saving a photo and using it straight away swift - webservice


ios,swift,camera,photo,alamofire
I have the following code for taking a photo and saving it to the camera roll. I need to be able to use it there and then after saving without having to go back into the gallery and selecting it. I haven't found any examples on how to do this....

error when using Alamofire to download an image


ios,swift,alamofire
Trying to make a fix in a pre-existing project with Alamofire but I am getting an error. The code in question is: Alamofire.request(.GET, "https://www.domain.com/demo-mobile-images/dogs-blue.jpg" ).response { (request, response, data , error) in tableViewCell.backgroundImageView.image = UIImage(data: data, scale:1) } but I get error: Cannot invoke 'response' with an argument list of...

Saving image from url to disk not working


objective-c,uiimage,afnetworking,afnetworking-2
I'm trying to download an image from an url in my app, so that it can be used by the Today Extension. So I call [self downloadImageFromUrl:imageOne];, which uses this method: - (void)downloadImageFromUrl:(NSString *)url { NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]]; AFHTTPRequestOperation *requestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; requestOperation.responseSerializer = [AFImageResponseSerializer...

returning a value from a function with Alamofire and SwiftyJson


swift,alamofire,swifty-json
I have an app that returns a menu of information (basically menus, menu_headers, and items). I'd like to have something like this: EKMenu.getMenu(menu_id: Int) that would return a menu but I think I would need a completion handler in here. I currently have: class func getMenu(menu_id: Int){ //class func getMenu(menu_id:...

How can I POST an NSArray of NSDictionaries inside an NSDictionary without problems?


php,ios,objective-c,json,afnetworking-2
I do know how to do this, it's fairly simple. The problem is that it doesn't work. Here's the function I use to POST the data: - (void)updateWebsitesUsingParameters:(NSDictionary *)parameters; { AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; [manager POST:@"http://notreal/updateWebsites.php" parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) { NSLog(@"JSON: %@", responseObject); //... } failure:^(AFHTTPRequestOperation *operation,...

Alamofire Priority Queue


ios,swift,queue,alamofire
I am using Alamofire as my networking library for my Swift app. Is there a way to keep a "priority queue" of network requests with Alamofire? I believe I saw this feature in a library in the past but I can no longer find it or find other posts about...

Swift Async Alamofire return


swift,asynchronous,alamofire
I'm getting an empty value on return annotations, I am sure this is because of the async scope, Ive tried everything to get var annotations: [TestAnnotation] = [] to return the values but I can't. The loop is correctly appending the values within the makeRequest scope. func makeRequest(url : String,...

Response Headers and URL in AFNetworking


ios,objective-c,cocoa-touch,afnetworking-2,nsurlsession
I am using AFNetworking to upload video and Image to a server. NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:urlString parameters:dictParams constructingBodyWithBlock:^(id<AFMultipartFormData> formData) { [formData appendPartWithFileData:imgData name:@"photo" fileName:@"photo.jpg" mimeType:@"image/jpeg"]; [formData appendPartWithFileData:[NSData dataWithContentsOfFile:pathVideo] name:@"video" fileName:@"video.mp4" mimeType:@"video/mp4"]; } error:nil];...

iOS: doubts about Alamofire vs AFNetworking


ios,swift,afnetworking-2,alamofire
now I'm starting a new app Universal (min versione iOS 7) and I want use Switf (it's my second app with this new language) In this app I need the framework AFNetworking, but I have some doubts about compatibility with the new version Alamofire. I know that there are some...

String is not convertible to String:AnyObject


swift,nsurlrequest,alamofire
I am trying out the Alamofire helpers for networking with my server. I am building up a router for handling my API endpoints. The construction itself seems clear to me, but I am struggling with some SWIFT syntax. enum Router:URLRequestConvertible { static let baseURLString = "url" case AEDS var URLRequest:...

building objects from json response using NSJSONSerialization


json,swift,alamofire
Using swift 1.2, xcode 6.3 and IOS 8, Im trying to build an object from a json response using NSJSONSerialization class. the json response is: [{ "_id" : "5470def9e0c0be27780121d7", "imageUrl" : "https:\/\/s3-eu-west-1.amazonaws.com\/myapi-static\/clubs\/5470def9e0c0be27780121d7_180.png", "name" : "Mondo", "hasVip" : false, "location" : { "city" : "Madrid" } }, { "_id" : "540b2ff281b30f3504a1c72f",...

remote data fetching inside model object in objective c using AFNetworking


ios,objective-c,rest,model-view-controller,afnetworking-2
In all of my iOS application I use this approach to respect MCV, I want to be sure that my implementation is correct and respects the best practices and the MVC design pattern : Singleton of AFNetworking acting as API for network calls: MyAPI.h : #import "AFHTTPSessionManager.h" #import "AFNetworking.h" @interface...

AFNetworking GET Parameters in body


ios,web-services,afnetworking-2
I have the following code and I want to force the parameters to be in the body of the GET call and not part of the query string NSString * requestURL = [NSString stringWithFormat:kXXXBaseAPIURL,@"findfriends"]; NSString * lastCallTime = [[XXXCommon sharedInstance] lastTimestampForURL:requestURL]; AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; AFHTTPRequestSerializer * serializer =[AFJSONRequestSerializer...

Image not uploaded on server in iOS


php,ios,objective-c,image-uploading,afnetworking-2
i want to upload an image on to server my image view image for that i write a code like as UIImage *image = self.uploadImageView.image; NSData *imageData = UIImageJPEGRepresentation(image, 0.5); AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; [manager POST:@"http://199.16.128.49/~gzfknsfg/webservices/insert_image.php?foldername=comm_image&img_name=iosimage.jpeg" parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) { [formData appendPartWithFormData:imageData...

Swift Alamofire SwiftyJSON Asynchronous/Synchronous Class Methods


swift,asynchronous,synchronous,alamofire,swifty-json
So I currently have the following: class ViewController: UIViewController { class Identity{ let baseUrl = "superSecretURL" var _username: String = "" var _password: String = "" var _apiKey: String = "" init(){ } init(username: String, apiKey: String){ _username = username _apiKey = apiKey } init(username: String, password: String){ _username =...

How to check Alamofire request has completed


ios,swift,alamofire
I am developing an iPad application using Swift. For http requests I use Alamofire library. So far I have managed to pull some data from an API. But the problem is since it is an asynchronous call I don't know how to check whether the request has completed. Any help...

Alamofire breaks other pods


cocoapods,alamofire
When I add alamofire to my Podfile it breaks all the others. I think it's because of the frameworks thing? Basically where I used to have this in my bridging header: #import <AFNetworking.h> now it says it can't find AFNetworking.h Does that for all of the headers that I get...

Is there a failed block for Alamofire?


ios,swift,alamofire
I'm using Alamofire with Swift kind of this way: Alamofire.request(.GET, urlString) .authenticate(usingCredential: credential) .response { (request, responseJSON, data, error) in [..and so on] Now I wonder how I can execute some code in case the server is e.g. completely down. Something like a failed block in ObjC. I know that...

Error handling in Alamofire


ios,angularjs,swift,alamofire
I have the HTTP code in an AngularJS controller: $http.post('/api/users/authenticate', {email: $scope.email, password: $scope.password}) .success(function (data, status, headers, config) { authService.login($scope.email); $state.go('home'); }) .error(function (data, status, headers, config) { $scope.errorMessages = data; $scope.password = ""; }); In the success case, the server will respond with a JSON representation of a...

How to send HTTP POST request with AFNetworking?


ios,objective-c,afnetworking-2
I have a remote address here: http://damp-sands-2243.herokuapp.com/students I need to insert new students via API call. Here is how I did it with javasript: var data = {"name":"Meg", "regi_number":38}; $(document).ready(function(){ $.ajax({ type: "POST", url: "/students/", contentType: "application/json; charset=utf-8", dataType: "json", data: JSON.stringify(data), success: function(){console.log("boo");} }); }); You can go to...

How to modify a method from category which is added using cocoapods


ios,objective-c,cocoapods,afnetworking-2
I have added AFNetworking using cocoapods and I need to modify UIActivityIndicatorView+AFNetworking.m category, and more specific I need to add a custom logging statement used in my project to the end of dealloc method. - (void)dealloc { NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil];...

Use of __IPHONE_OS_VERSION_MIN_REQUIRED without comparison


ios,afnetworking-2
In AFNetworking 2.0, NSHTTPSessionManager.h has the following code: #if __IPHONE_OS_VERSION_MIN_REQUIRED #import <MobileCoreServices/MobileCoreServices.h> #else #import <CoreServices/CoreServices.h> #endif __IPHONE_OS_VERSION_MIN_REQUIRED is used without specifying a version to compare to. Why? Is it because this macro is defined when Core Services framework is changed to MobileCoreServices.h?...

AFNetworking 2.5.3 Serialization of array to send indexes explicitely


ios,afnetworking-2
I use AFHTTPRequestSerializer *serializer = [AFHTTPRequestSerializer serializer]; and this sends out the call to the server when having an array in the format: payments[] payments[][email]=0& payments[][category]=& payments[][email]=1& payments[][category]=& I need the indexes for the server like. payments[] payments[0][email]=0& payments[0][category]=& payments[1][email]=1& payments[1][category]=& How can I achieve that? Thanks....

CocoaPods not installing Alamofire in Swift Parse Chat App


xcode,swift,parse.com,cocoapods,alamofire
I am trying to compile and run the following application (Swift Chat App using Alamofire). https://github.com/huyouare/SwiftParseChat I am using ruby-2.0.0 , cocoapods 0.37.1, xcode 6.3, Alamofire 1.2.0 I am installing it using the normal <pod install> command. No errors or warnings during the process. However, when compiling, I get: No...

Alamofire.request vs. manager.request - manager not working


ios,swift,alamofire
EDIT: the question was not about what -999 means, but why do I not get an error with the first code fragment, but with the second? Apart of using the Alamofire.Manager in the second code snippet (that should work identical to the Alamofire.request in the first code snippet), everything is...

UIProgressView progress update very slow within AlamoFire (async) call


swift,uiprogressview,alamofire,nsnotification,dispatch-async
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...

imageWithRenderingMode doesn't work with setImageWithUrl (for tintColor)


ios,afnetworking-2
I can tint a UIImage in a UIImageView using : imageView = [[UIImageView alloc]initWithImage:[myImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]]; imageView.tintColor = [UIColor redColor]; But when the image is initialized with AFNetworking's setImageWithUrl : imageView = [imageView setImageWithUrl:url]; imageView.image = [imageView.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; imageView.tintColor = [UIColor redColor]; This has no effect, the image is displayed with...

Issues with calling a function that has to wait for a server response


ios,json,swift,alamofire,completionhandler
So I have the following code in my view controller that works perfectly. I make the json request, the server call is made and I get the response no issues. My function is called on a button click: @IBAction func buttonClick(sender: AnyObject) { var postsEndpoint = "http://test.com/test" let test =...

SwiftyJSON - no access to JSON data


swift,alamofire,swifty-json
I'm trying to parse server response produced by following code (api for rails app developed with grape) if user.persisted? return user.to_json else error!(user.errors.to_json, 400) end When user submit wrong data i see following response from server: { response = "{\"email\":[\"is invalid\"],\"password\":[\"is too short (minimum is 8 characters)\"]}"; "response_type" = error;...

Why is not recommended to modify session configuration for authorization headers in Alamofire?


swift,alamofire
From: https://github.com/Alamofire/Alamofire Modifying Session Configuration ... example code ... This is not recommended for Authorization or Content-Type headers. Instead, use URLRequestConvertible and ParameterEncoding, respectively. Ok, I will not use it, but why it is not recommended for handling Authorization headers?...

AFNetworking 2.0 header Content-Type not being sent on POST call


ios,objective-c,afnetworking-2
I'm trying to convert some NSURLConnection code to AFNetworking 2.0 and I'm having issues with the POST calls. The GET calls work but not the POST. Here's my code: +(void)login:(User*)myUser { AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; manager.requestSerializer = [AFJSONRequestSerializer serializer]; [manager.requestSerializer setAuthorizationHeaderFieldWithUsername:myUser.username password:myUser.password]; [manager.requestSerializer setValue:@"application/x-www-form-urlencoded"...

Alamofire not sending upload-request (no connection established at all)


ios,swift,upload,alamofire
I want to upload a file, which has recently been downloaded (in my app) from the DocumentPicker (e.g. iCloud, Dropbox, ...) So I have the NSUrl (urlToFile) of this file (verified) I use this code to upload: upload(.POST, Config.uploadURL, urlToFile!) .progress { (bytesWritten, bytesWrittenInTotal, bytesToBeWritten) -> Void in println("Bytes: \(bytesWrittenInTotal)")...

How to use swiftyjson to parse json data to foundation object and loop through data


swift,alamofire,swifty-json
So I'm trying to get his raw json data and use it to ultimately be viewed in a table(so one table cell would be --> Emirates - $1588.77) Problem: Having trouble parsing the JSON data.. alamofire apparently does it automatically? but im completely confused with the data types. I keep...

Alamofire request JSON


json,swift,alamofire
I need to make a request to the following JSON { "usuario": { "nmeUsuario": "name", "username": "TestUsername", "senha": "46070d4bf934fb0d4b06d9e2c46e346944e322444900a435d7d9a95e6d7435f5" }, "sistemaId": "2", "contatos": [ { "desContato": "[email protected]", "idTipoContato": { "idTipoContato": 1 } } ] } I tried the following code let senha = "46070d4bf934fb0d4b06d9e2c46e346944e322444900a435d7d9a95e6d7435f5" let usuario = ["nmeUsuario":"name","username":"TestUsername","senha":senha] let idContato...

Swift ios alamofire data returning empty first time in viewDidLoad


ios,swift,api,model-view-controller,alamofire
I am trying to load data from an API into my viewcontroller but the first time it loads the data returns empty import UIKit class AdViewController: UIViewController { var adId: Int! var adInfo: JSON! = [] override func viewDidLoad() { super.viewDidLoad() loadAdInfo(String(adId),page: 1) println(adInfo) // This shows up as empty...

AlamoFire asynchronous completionHandler for JSON request


swift,alamofire
Having used the AlamoFire framework I've noticed that the completionHandler is run on the main thread. Im wondering if the code below is a good practice for creating a Core Data import task within the completion handler: Alamofire.request(.GET, "http://myWebSite.com", parameters: parameters) .responseJSON(options: .MutableContainers) { (_, _, JSON, error) -> Void...

Alamofire RED in Xcode project - No Alamofire.framework file


ios,xcode,swift,xcode6,alamofire
I'm trying to install Alamofire into my Xcode project. However, after following all the steps for installation given by the documentation on the github project, the Alamofire.framework file shows as red in Xcode, and the project will not build. Further, there seems to be no way to fix this, because...

iOS: (Swift) How to show distance from current location and exist annotation on annotation subtitle


ios,swift,annotations,mapkit,alamofire
I am currently working on map application base on iOS using Swift language. I would like an suggestion because after I plot all the pins on map view (which I receive data from my server using JSON frameworks call Alamofire) I would like the subtitle of all annotations on map...