-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathViewController.m
111 lines (77 loc) · 4 KB
/
ViewController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
//
// ViewController.m
// example
//
// Created by macmini on 2/11/17.
// Copyright © 2017 OUorg. All rights reserved.
//
#import "ViewController.h"
#import "SWRevealViewController.h"
#import "AFNetworking.h"
@interface ViewController (){
NSURLSession*url;
NSURLSessionDataTask*datatask;
NSURLSessionConfiguration*urlconfig;
NSMutableURLRequest*urlreq;
NSMutableString*dict;
NSMutableArray*arr;
}
@end
@implementation ViewController
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
return 14;
}
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
UICollectionViewCell*cell=[collectionView dequeueReusableCellWithReuseIdentifier:@"item" forIndexPath:indexPath];
[cell setFrame:CGRectMake(6, 0, self.clctVw.frame.size.width, 90)];
return cell;
}
- (void)viewDidLoad {
[super viewDidLoad];
dict=[NSMutableString new];
_seg.layer.borderColor=[UIColor clearColor].CGColor;
_seg.layer.borderWidth=2;
[self.menu addTarget:self.revealViewController action:@selector(revealToggle:) forControlEvents:UIControlEventTouchUpInside];
//self.menu.action=@selector(revealToggle:);
[self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer];
// Do any additional setup after loading the view, typically from a nib.
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
[manager setResponseSerializer:[AFJSONResponseSerializer serializerWithReadingOptions:NSJSONReadingAllowFragments]];
[manager GET:[NSString stringWithFormat:@"http://103.231.100.207/EmpAdminAPI/api/admin/GetTaskDetails"] parameters:nil progress:nil success:^(NSURLSessionTask *task, id responseObject) {
NSError*err;
NSData* data1 = [responseObject dataUsingEncoding:NSUTF8StringEncoding];
arr=(NSMutableArray*)[NSJSONSerialization JSONObjectWithData:data1
options:NSJSONReadingMutableContainers
error:&err];
} failure:^(NSURLSessionTask *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)proceed:(id)sender {
NSString* Identifier = [[[UIDevice currentDevice] identifierForVendor] UUIDString]; // IOS 6+
NSLog(@"output is : %@", Identifier);
urlreq = [[NSMutableURLRequest alloc]initWithURL:[NSURL URLWithString:@"http://103.231.100.207/DemoAPI/api/Leaves/GetLoginDetails"]];
urlconfig = [NSURLSessionConfiguration defaultSessionConfiguration];
url = [NSURLSession sessionWithConfiguration:urlconfig];
[urlreq setValue:@"application/x-www-form-urlencoded; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[urlreq setHTTPMethod:@"GET"];
NSString *post = [[NSString alloc] initWithFormat:@"emailid=%@&mobilenumber=%@&photodata=%@&deviceinfo=%@",self.frstTF.text,self.scndTF.text,nil,Identifier];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%lu",(unsigned long)[postData length]];
[urlreq setValue:postLength forHTTPHeaderField:@"Content-Length"];
[urlreq setHTTPBody:postData];
datatask=[url dataTaskWithRequest:urlreq completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
NSLog(@"data recieved");
dict=[NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
NSLog(@"output is to be %@",dict);
// otpVC*otp=[self.storyboard instantiateViewControllerWithIdentifier:@"otpVC"];
// [self presentViewController:otp animated:YES completion:nil];
}];
[datatask resume];
}
@end