afnetworking

AFNetworking and Swift - Save json response

核能气质少年 提交于 2019-12-05 01:39:24
问题 I want to make a GET request in swift to get some Json data. I tried to use AFNetworking and it works, but I don't know how to return the Json I get. I tried with a return but it's made before the GET so I get nothing... func makeGet(place:String) -> String { var str:String = "" let manager = AFHTTPRequestOperationManager() manager.requestSerializer.setValue("608c6c08443c6d933576b90966b727358d0066b4", forHTTPHeaderField: "X-Auth-Token") manager.GET("http://something.com/api/\(place)",

Passing blocks to a AFNetworking method?

主宰稳场 提交于 2019-12-05 01:24:36
问题 -(void )getDataFromServer: (NSMutableDictionary *)dict { NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@/doSomething",MainURL ]]; [AFJSONRequestOperation addAcceptableContentTypes:[NSSet setWithObject:@"text/html"]]; AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url]; NSMutableURLRequest *request = [httpClient requestWithMethod:@"POST" path:nil parameters:dict]; AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest

A server with the specified hostname could not be found in AFNetworking

风流意气都作罢 提交于 2019-12-05 01:11:44
问题 I switch out AFnetworking API from ASIHTTPRequest in my app for connection error issues. But now I'm getting connection error in AFNetworking . How can I resolve this? Printing description of error: Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found." UserInfo=0x1553bab0 {NSErrorFailingURLStringKey=https://example.com/oauth/token, NSErrorFailingURLKey=https://example.com/oauth/token, NSLocalizedDescription=A server with the specified hostname

AFNetworking and Swift

前提是你 提交于 2019-12-05 00:01:32
I'm trying to get a JSON response using Swift. I sniffed the request and response -> everything ok. However the return value is always nil . let httpClient = AppDelegate.appDelegate().httpRequestOperationManager as AFHTTPRequestOperationManager; let path = "/daten/wfs"; let query = "?service=WFS&request=GetFeature&version=1.1.0&typeName=ogdwien:AMPELOGD&srsName=EPSG:4326&outputFormat=json".stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding); func successBlock(operation: AFHTTPRequestOperation!, responseObject: AnyObject!) { println("JSON: " + "\(responseObject)") } func errorBlock

学习笔记整理

元气小坏坏 提交于 2019-12-05 00:00:22
写iOS 程序的时候往往需要很多第三方框架的支持,可以大大减少工作量,讲重点放在软件本身的逻辑实现上。 GitHub 里面有大量优秀的第三方框架,而且 License 对商业很友好。一下摘录一下几乎每个项目都想集成的几个框架。 1. Mantle Mantle 让我们能简化 Cocoa 和 Cocoa Touch 应用的 model 层。简单点说,程序中经常要进行网络请求,请求到得一般是 json 字符串,我们一般会建一个 Model 类来存放这些数据。这就要求我们编写一系列的序列化代码,来把 json 转换为 Model 。这很费时间,容易错,不容易修改。 Mantle 很好的解决了这个问题,而且更易用。 GitHub : https://github.com/Mantle/Mantle 参考: 工具篇: Mantle 源码篇: Mantle CocoaPod 集成: pod 'Mantle', '~> 1.5.4' 2. Masonry IB 时代,如果你还在用代码绝对布局就太 low 了。随着苹果发布 iPhone6 、 iPhone 6 plus 。 iOS 设备将会出现越来越丰富的屏幕尺寸,我们不可能根据每个尺寸做一套布局。所以,使用 autolayout 就很有必要了。在 storyboard 中,可以非常方便的使用 autolayout ,但是为了更好的协作开发

Get UIImageView using Afnetworking and put it in an array

◇◆丶佛笑我妖孽 提交于 2019-12-04 21:46:46
As the title says, i need to get the image and put it in an array. UIImageView *myImage = [[UIImageView alloc] init]; [myImage setImageWithURL:[NSURL URLWithString:@"http://host.com/images/1/1.png"] placeholderImage:[UIImage imageNamed:@"page3.png"]]; [items addObject:myImage]; the problem is that while the image is being loaded, the code continues and nothing gets put in the array, actually I guess an empty UIImageView gets inserted. How do I go about fixing this? On a side note I am using iCarousel to display images, in the data source it gets the images array and shows them. Can i modify

Unable to upload large videos to Facebook from iOS app

核能气质少年 提交于 2019-12-04 21:30:39
I am trying to upload large files video files to Facebook, but regardless of the approach taken, the result is always the same. The process uploads between 5-35mb worth of data then times out. This happens on WiFi. I have tried with the Facebook SDK 3.1.1, iOS Social Library (i.e. SLRequest) and AFNetworking. The social library and afnetworking give time out errors, whereas the Facebook SDK just returns a Code 5, Operation Could Not Be Completed, HTML Error 200 but if I watch the network activity via instruments it has the same signature, that being a certain amount of megabytes being uploaded

Using SSLSetEnabledCiphers with AFNetworking to disable weak ciphers

╄→尐↘猪︶ㄣ 提交于 2019-12-04 21:20:15
问题 I am trying to disable some ciphers (weak) such as single DES, single DES 40 bit etc. I've tried using this bit of code from How does one set SSL ciphers when using CFSocket/CFStream in Cocoa? and from mailing list message CFNetwork SSL and long blocking delays but I need access to socket data to get the CFDataRef . Here is the code that I tried to insert in the handshake method in AFURLConnectionOperation class: - (void)connection:(NSURLConnection *)connection

iOS Caching images with AFImageCache doesn't seem to work

百般思念 提交于 2019-12-04 21:11:48
I'm trying to cache some images loaded from a URL by using AFImageCache, without success... I'm not sure If i'm doing anything wrong and would love your opinions if you've ever used this library. I'm getting an image from a NSURLRequest, and then caching it as follows UIImage *img; //This image is a png icon returned from the server NSData *imgData = UIImagePNGRepresentation(img); // Always checking length to make sure its more than 0, and it is [[AFImageCache sharedImageCache] cacheImageData: imgData forURL: myURL cacheName: @"IconCache"]; On the next run, i'll try to check if the image was

How should I pre-load all images and cache them using AFNetworking?

萝らか妹 提交于 2019-12-04 20:48:57
I need to pre-load and cache all (Nearly 80) images in the beginning of the application, while showing "Please Wait" to the user. What I did is: NSMutableArray *operations = [[NSMutableArray alloc] init]; for(Category *c in shop.menu.categories){ NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:c.imagePath] cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:30]; AFImageRequestOperation *operation = [AFImageRequestOperation imageRequestOperationWithRequest:request imageProcessingBlock:nil cacheName:@"nscache" success:^(NSURLRequest *request,