-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNewPostViewController.m
More file actions
93 lines (65 loc) · 2.6 KB
/
NewPostViewController.m
File metadata and controls
93 lines (65 loc) · 2.6 KB
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
//
// NewPostViewController.m
// SeetiTel
//
// Created by Immanuel Amirtharaj on 5/2/15.
// Copyright (c) 2015 Immanuel Amirtharaj. All rights reserved.
//
#import "NewPostViewController.h"
@interface NewPostViewController ()
@end
@implementation NewPostViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
// if (type == 0)
// {
// self.whistleTextView = [[UITextView alloc] initWithFrame:CGRectMake(50, 100, 200, 300)];
//
// [self.whistleTextView setBackgroundColor:[UIColor blackColor]];
//
// [self.whistleTextView setTextColor:[UIColor whiteColor]];
//
// [self.view addSubview:self.whistleTextView];
//
// }
//
// else if (type == 1)
// {
//
// self.whistleView = [[UIImageView alloc] initWithFrame:CGRectMake(50, 10, 200, 300)];
//
// [self.whistleView setImage:self.whistleImage];
//
// [self.view addSubview:self.whistleView];
//
//
// }
self.whistleTextView.layer.borderWidth = 0.5f;
[self.whistleTextView.layer setBorderColor:[[UIColor blackColor] CGColor]];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
- (IBAction)postButtonPressed:(id)sender {
NSURL *requestURL = [NSURL URLWithString:@"http://168.235.152.38:8080/api/v1/whistle/new/"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:requestURL
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
NSString *whistleString = [self.whistleTextView text];
NSString *postString = @"type=0&data=";
postString = [postString stringByAppendingString:whistleString];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:[postString dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection *connection= [[NSURLConnection alloc] initWithRequest:request
delegate:self];
[self.navigationController popToRootViewControllerAnimated:YES];
}
@end