afnetworking

How to set Timeout Interval with AFHTTPClient in AFNetworking?

喜你入骨 提交于 2019-12-08 08:59:59
问题 How to set time interval with AFHttpClient AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@""]]; [httpClient setParameterEncoding:AFJSONParameterEncoding]; [httpClient registerHTTPOperationClass:[AFJSONRequestOperation class]]; 回答1: The time out information is part of the NSURLRequest that you need to create and then feed to the client: AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@""]]; [httpClient

Importing with MagicalRecord + AFNetworking

为君一笑 提交于 2019-12-08 08:47:14
问题 I'm using AFNetworking and MagicalRecord (the current develop branch) and I'm trying to figure out how to import a lot of objects which are dependent on each other. Each resource/entity has multiple pages worth of downloads. I have a class managing the downloads for a given entity and saving them using MagicalDataImport (which has been amazing). I believe my issue is that the imports aren't happening on the same thread. So I think what is happening is: In one thread, EntityA is getting saved

GET request using AFNetworking and saving response

≡放荡痞女 提交于 2019-12-08 07:45:10
问题 I am doing a simple GET request with AFNetworking AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; [manager GET:@"http://someapi.com/hello.json" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) { NSLog(@"JSON: %@", responseObject); } failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSLog(@"Error: %@", error); }]; Once I have made the request I want to be able to access the responseObject from any other method in the

AFNetworking PUT and Delete with Rails

て烟熏妆下的殇ゞ 提交于 2019-12-08 07:33:23
问题 In looking at the AFNetworking documentation, the Put and Delete methods take in a path and a dictionary of parameters. I am using Rails as my backend which expects these two types to take the form of Put /object/1.json and Delete /object/1.json. Should I build up a path string by adding in the Id or do I send a Put or Delete with the Id as one of the params in the Dictionary? 回答1: Typically when I do with PUT and similar type HTTP requests when using AFNetworking is something like this: //

In-app purchase receipt verification for auto renewal using AFNetworking objective-c

一曲冷凌霜 提交于 2019-12-08 06:13:16
问题 I am writing below code using AFNetworking for receipt verification and it gives me status=210002 While it gives me status=0 in NSMutableURLRequest please help me by getting solution NSString *strurl = @"https://sandbox.itunes.apple.com/verifyReceipt"; NSData *receipt = [NSData dataWithContentsOfURL:[[NSBundle mainBundle] appStoreReceiptURL]]; NSDictionary *parameter=@{ @"receipt-data" : [receipt base64EncodedStringWithOptions:0], @"password" : @"xxxxxxxxxxxxxxxxxxxx", }; NSData *jsonParam =

Asynchronous downloading in UICollectionView error with AFNetworking

我与影子孤独终老i 提交于 2019-12-08 05:58:14
问题 Hi I'm creating Uicollection view with list ofcatalogs, While tapping on cell the PDF have to download, Its working in one view perfectly but in another view gives the error * thread #1: tid = 0x4b2ce, 0x000000018d14f9b8 CoreFoundation`CFURLCopyScheme + 56, queue = 'com.apple.NSURLSession-work', stop reason = EXC_BAD_ACCESS (code=1, address=0x0) frame #0: 0x000000018d14f9b8 CoreFoundation`CFURLCopyScheme + 56 frame #1: 0x000000018cdab96c CFNetwork`_urlIsHTTPish + 16 frame #2:

How to add “Load more” page when scrolling to bottom of table

孤者浪人 提交于 2019-12-08 05:48:51
问题 I'm trying to figure out the best way to handle paging or a "Load More..." when scoll to bottom in a UItableView. I'm loading this data from a web service, that's pretty flexible, giving me a pagesize and page parameter. Pagesize defines the number of results pulled back each time, whereas the page parameter defines groups of search results, for example: page=1 (returns results 1-10). page=2 (returns results 11-20) Each time, when scroll down to bottom, i request to server 1 time and server

AFNetworking send image as file not as data

蓝咒 提交于 2019-12-08 05:25:09
问题 Hi server that I'm sending data is expecting image as file(jpg) not as NSData. This code works, but server can't recognize NSData as image. Any thoughts how to solve this? + (void)signupWithParameters:(NSDictionary *)parameters andUserHaveImage:(BOOL)userHaveImage andImage:(NSData *)image successBlock:(void (^) (NSDictionary *response))successHandler errorBlock:(void (^) (NSDictionary *error))errorHandler { AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; manager

Invalid top-level type in JSON write in Swift

泪湿孤枕 提交于 2019-12-08 04:48:11
问题 i'm trying to do a PUT using AFNetworking. I need to send an array of participants in a competition, but i'm getting the "Invalid top-level type in JSON write in Swift" error. The JSON I generate is perfect, and if I try it using REST Client everything works. Here's my code: func sendUsers(onComplete: (NSError?) -> Void) { var error: NSError? var jsonData: NSData = NSJSONSerialization.dataWithJSONObject(self.createDictionaryOfParticipations(), options: NSJSONWritingOptions.allZeros, error:

AFNetworking Offline Queue

ⅰ亾dé卋堺 提交于 2019-12-08 02:16:49
问题 Currently I am queueing a simple offline request using AFHTTPRequestOperationManager and it doesn't seem to work in the desired manner: Here is the responsible code and below are different execution patterns: @interface ViewController () { AFHTTPRequestOperationManager *manager; } @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; manager = [AFHTTPRequestOperationManager manager]; NSOperationQueue *operationQueue = manager.operationQueue; [