Guest User

Untitled

a guest
Aug 6th, 2013
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #import "ViewController.h"
  2.  
  3. @interface ViewController ()
  4.  
  5. @end
  6.  
  7. @implementation ViewController
  8. @synthesize Label, Name, Stav, Stav2;
  9.  
  10. -(IBAction)Button1:(id)sender
  11. {
  12.     NSMutableURLRequest *urlRequest = [[[NSMutableURLRequest alloc] init] autorelease];
  13.     NSString *urlString = [NSString stringWithFormat:@"http://freetech.sk/test.php?name=%@",Name.text];
  14.     [urlRequest setURL:[NSURL URLWithString:urlString]];
  15.    
  16.     NSData *urlData;
  17.     NSURLResponse *response;
  18.     NSError *error;
  19.     urlData = [NSURLConnection sendSynchronousRequest:urlRequest returningResponse:&response error:&error];
  20.     if(!urlData) {
  21.         Stav.text = @"Nepodarilo sa pripojit.";
  22.     }
  23.     else
  24.     {
  25.         NSString *aStr = [[[NSString alloc] initWithData:urlData encoding:NSUTF8StringEncoding]autorelease];
  26.         if([aStr isEqualToString: @"1"])
  27.         {
  28.             Free.hidden = YES;
  29.             Stav2.hidden = YES;
  30.             booked.hidden = NO;
  31.             Stav.hidden = NO;
  32.         }
  33.         else
  34.         {
  35.             booked.hidden = YES;
  36.             Stav.hidden = YES;
  37.             Free.hidden = NO;
  38.             Stav2.hidden = NO;
  39.         }
  40.     }
  41.  
  42. }
  43.  
  44. -(void) textFieldShouldReturn: (id) sender
  45. {
  46.     [sender resignFirstResponder];
  47. }
  48.  
  49. -(IBAction)dismissKeyboard
  50. {
  51.     [Name resignFirstResponder];
  52. }
  53.  
  54. - (void)viewDidLoad
  55. {
  56.     [super viewDidLoad];
  57.     Stav.hidden=YES;
  58.     Stav2.hidden=YES;
  59.  
  60.  
  61. }
  62.  
  63. - (void)didReceiveMemoryWarning
  64. {
  65.     [super didReceiveMemoryWarning];
  66.     // Dispose of any resources that can be recreated.
  67. }
  68.  
  69. - (void)dealloc {
  70.     [super dealloc];
  71. }
  72. @end
Advertisement
Add Comment
Please, Sign In to add comment