Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import "ViewController.h"
- @interface ViewController ()
- @end
- @implementation ViewController
- @synthesize Label, Name, Stav, Stav2;
- -(IBAction)Button1:(id)sender
- {
- NSMutableURLRequest *urlRequest = [[[NSMutableURLRequest alloc] init] autorelease];
- NSString *urlString = [NSString stringWithFormat:@"http://freetech.sk/test.php?name=%@",Name.text];
- [urlRequest setURL:[NSURL URLWithString:urlString]];
- NSData *urlData;
- NSURLResponse *response;
- NSError *error;
- urlData = [NSURLConnection sendSynchronousRequest:urlRequest returningResponse:&response error:&error];
- if(!urlData) {
- Stav.text = @"Nepodarilo sa pripojit.";
- }
- else
- {
- NSString *aStr = [[[NSString alloc] initWithData:urlData encoding:NSUTF8StringEncoding]autorelease];
- if([aStr isEqualToString: @"1"])
- {
- Free.hidden = YES;
- Stav2.hidden = YES;
- booked.hidden = NO;
- Stav.hidden = NO;
- }
- else
- {
- booked.hidden = YES;
- Stav.hidden = YES;
- Free.hidden = NO;
- Stav2.hidden = NO;
- }
- }
- }
- -(void) textFieldShouldReturn: (id) sender
- {
- [sender resignFirstResponder];
- }
- -(IBAction)dismissKeyboard
- {
- [Name resignFirstResponder];
- }
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- Stav.hidden=YES;
- Stav2.hidden=YES;
- }
- - (void)didReceiveMemoryWarning
- {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- - (void)dealloc {
- [super dealloc];
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment