Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (void) getData
- {
- NSMutableURLRequest *req = [[AFJSONRequestSerializer serializer] requestWithMethod:@"GET" URLString:@"http://----------" parameters:nil error:nil];
- AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
- req.timeoutInterval= 15;
- [req setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
- [req setValue:@"application/json" forHTTPHeaderField:@"Accept"];
- self.dataTask = [manager dataTaskWithRequest:req completionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error)
- {
- if (!error)
- {
- NSLog(@"Reply JSON >>>>>> responseObject <<<<<: %@", responseObject);
- if ([responseObject isKindOfClass:[NSDictionary class]])
- {
- if (self.delegate && [self.delegate respondsToSelector:@selector(success:)]) {
- [self.delegate success:responseObject];
- }
- // self.colorView.backgroundColor = [UIColor blueColor];
- return;
- }
- else
- {
- NSLog(@"Error No dictionary: %@, %@, %@", error, response, responseObject);
- {
- // self.colorView.backgroundColor = [UIColor redColor];
- [self.delegate error:error];
- return;
- }
- }
- }
- else
- {
- NSLog(@"Error: %@, %@, %@", error, response, responseObject);
- [self.delegate error:error];
- return;
- }
- }];
- [self.dataTask resume];
- if (self.cancelRequest) {
- [self.dataTask cancel];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement