afnetworking

PHAsset + AFNetworking. Unable to upload files to the server on a real device

喜你入骨 提交于 2019-12-18 13:58:30
问题 Currently I'm using the following code to upload files to the server NSURLRequest *urlRequest = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:[[entity uploadUrl]absoluteString] parameters:entity.params constructingBodyWithBlock:^(id<AFMultipartFormData> formData) { // Get file url [UploadModel getAassetUrl:entity.asset resultHandler:^(NSURL *fileUrl) { NSError *fileappenderror; // Append [formData appendPartWithFileURL:fileUrl name:@"data" error:

Cocoapods + Cannot load underlying module for 'x'

被刻印的时光 ゝ 提交于 2019-12-18 11:14:27
问题 I am running XCode 7, Swift 2.0, iOS 9. I want to install Alamofire in my project using Cocoapods. I have done the following: gem install cocoapods pod setup pod init Updated Podfile to: # Uncomment this line to define a global platform for your project # platform :ios, '9.0' use_frameworks! target 'JSONeg' do pod 'Alamofire', :branch => 'swift-2' end Then I installed the pod: pod install And I added the following to ViewController.swift import Alamofire This raises the following error:

Bypassing http response header Cache-Control: how to set cache expiration?

≯℡__Kan透↙ 提交于 2019-12-18 10:57:46
问题 All http responses from a server come with the headers that inform our app not to cache the responses: Cache-Control: no-cache Pragma: no-cache Expires: 0 So, if you are making NSUrlRequests with default cache policy "NSURLRequestUseProtocolCachePolicy" then the app will always load data from the server. However, we need to cache the responses and the obvious solution would be to set these headers to some time for example (at backend side), set to 10 seconds. But I'm interested in a solution

AFNetworking posts JSON arrays as multiple single-entry dictionaries

不羁岁月 提交于 2019-12-18 06:51:05
问题 I'm having a similar issue to the one discussed here. I'm attempting to post JSON to a server. Here's the Objective-C code that should work, but doesn't. I get an empty array in the response object, not sure why: AFHTTPRequestOperation * operation = [manager POST:uploadScriptUrl parameters:mutableJSON success:^(AFHTTPRequestOperation * operation, id responseObject) { successBlock(operation, responseObject); } failure:^(AFHTTPRequestOperation * operation, NSError * error) { failureBlock

Upload multiple images using AFNetworking

元气小坏坏 提交于 2019-12-18 06:47:52
问题 I used the PickerController and loaded a few images on to a NSMutableArray . Now i need to upload all of these images at once. am using AFNetworking and how can i do this? I went through the AFNetworking documentation and there was a section called Creating an Upload Task for a Multi-Part Request, with Progress . However, i am not able to upload the images that are in my NSMutableArray . **** NB: I want to upload the images in the NSMutableArray as a Byte Array. How can i do this? **** The

Upload multiple images using AFNetworking

一笑奈何 提交于 2019-12-18 06:47:42
问题 I used the PickerController and loaded a few images on to a NSMutableArray . Now i need to upload all of these images at once. am using AFNetworking and how can i do this? I went through the AFNetworking documentation and there was a section called Creating an Upload Task for a Multi-Part Request, with Progress . However, i am not able to upload the images that are in my NSMutableArray . **** NB: I want to upload the images in the NSMutableArray as a Byte Array. How can i do this? **** The

Swift execute asynchronous tasks in order

巧了我就是萌 提交于 2019-12-18 06:45:55
问题 I have a few asynchronous, network tasks that I need to perform on my app. Let's say I have 3 resources that I need to fetch from a server, call them A , B , and C . Let's say I have to finish fetching resource A first before fetching either B or C . Sometimes, I'd want to fetch B first, other times C first. Right now, I just have a long-chained closure like so: func fetchA() { AFNetworking.get(completionHandler: { self.fetchB() self.fetchC() }) } This works for now, but the obvious

AFNetworking框架使用

最后都变了- 提交于 2019-12-18 06:23:46
本文是由 iOS Tutorial 小组成员 Scott Sherwood 撰写,他是一个基于位置 动态加载( Dynamically Loaded )的 软件公司(专业的混合定位)的共同创办人。 网络 — 你的程序离开了它就不能生存下去!苹果的Foundation framework中的NSURLConnection又非常难以理解, 不过这里有一个可以使用的替代品: AFNetworking . AFNetworking 非常受开发者欢迎 – 它赢得了我们读者的青睐:2012年最佳的iOS Library奖( 2012 Best iOS Library Award .) 所以现在我就写这篇文章来向你介绍如何在程序中有效的使用它。 AFNetworking 包括了所有你需要与在线资源交互的内容,从web services到文件下载。当你的程序在下载一个大文件期间,AFNetworking还能确保你的UI是可以响应的。 本文将介绍AFNetworking框架主要的组成部分。一路上,你将使用 World Weather Online 提供的咨询(Feeds)来创建一个天气(Weather)程序。刚开始使用的天气数据是静态的,不过在学完本文内容之后,程序将连接到实时的天气咨询。 今日预计:一个很酷的开发者学习所有关于AFNetworking知识,并在他的程序中使用AFNetworking

How to convert ipv4 address to ipv6 use AFNetworking?

亡梦爱人 提交于 2019-12-18 05:25:44
问题 I've a problem with IPV6 . Apple reject my app with error: We discovered one or more bugs in your app when reviewed on iPad and iPhone running iOS 10.0.2 on Wi-Fi connected to an IPv6 network. Specifically, your app stayed static at the launch screen and there was no further content loaded. We've attached screenshot(s) for your reference. But my sever is not supporting IPV6 . I use library AFNetworking to connect server. Please help me some solution? Thank you for any support! 回答1: I got this

AFNetworking post image in nested json

戏子无情 提交于 2019-12-18 05:13:10
问题 I have to send a nested json request which includes an image in an inner hierarchy. eg: {"product" : { "catalogue_id" : "x", "name" : "my product", "image" : #<image> } } Problem is if I try using multipartFormRequestWithMethod:path:parameters:constructingBodyWithBlock: (and appendPartWithFileData:name:fileName:mimeType: ), passing in catalogue_id and name as params, the image field is appended after "product", like so: {"product" : { "catalogue_id" : "x", "name" : "my product" } , "image" :