Guest User

Untitled

a guest
Jun 19th, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. //
  2. // AuthenticationViewController.m
  3. // Authentication
  4. //
  5. // Created by Derek Hardison on 5/13/09.
  6. // Copyright __MyCompanyName__ 2009. All rights reserved.
  7. //
  8.  
  9. #import "AuthenticationViewController.h"
  10. #import "RCAuth.h"
  11. #import "RCEventSportAppDelegate.h"
  12. #import "EventsViewController.h"
  13.  
  14. @implementation AuthenticationViewController
  15.  
  16. - (void)viewDidLoad {
  17. appDel = (RCEventSportAppDelegate *) [[UIApplication sharedApplication] delegate];
  18. // ASSERT: Made connection with application delegate.
  19. eventsView = [[EventsViewController alloc] initWithNibName:@"EventsMain" bundle:nil];
  20. // ASSERT: Initialized the next view.
  21.  
  22. [[[[[appDel tabBarController] viewControllers] objectAtIndex:0] tabBarItem] setEnabled:NO];
  23. [[[[[appDel tabBarController] viewControllers] objectAtIndex:1] tabBarItem] setEnabled:NO];
  24. [[[[[appDel tabBarController] viewControllers] objectAtIndex:2] tabBarItem] setEnabled:NO];
  25. // ASSERT: Disable all of the tab bar buttons until the user has logged in.
  26.  
  27. [super viewDidLoad];
  28. }
  29.  
  30. // PRE: Takes an type 'id'.
  31. // POST: Returns type 'IBAction' which is essentially void.
  32. // Submits username and password to validation backend.
  33. - (IBAction) validateUser:(id) sender {
  34. RCAuth *rcA = [[RCAuth alloc] initWithUser:[username text] password:[password text]];
  35. // ASSERT: rcA now contains information about the user's login and password.
  36.  
  37. NSLog(@"OK %d", [rcA isLoggedIn]);
  38. if ([rcA isLoggedIn] == 1) {
  39. NSLog(@"before res");
  40. [(UITextField *)sender resignFirstResponder];
  41. NSLog(@"after res");
  42. // ASSERT: Remove the keyboard from the screen.
  43.  
  44. //[[self navigationController] pushViewController:eventsView animated:YES];
  45. // ASSERT: Notify the main program that the user has successfully
  46. // authenticated themselves.
  47. }
  48. else {
  49. [errorLabel setText:@"Invalid username or password."];
  50. }
  51.  
  52. NSLog(@"BEFORE REL");
  53. [rcA release];
  54. NSLog(@"After REL");
  55. }
  56.  
  57. - (IBAction) nextField:(id) sender {
  58. [(UITextField *) password becomeFirstResponder];
  59. }
  60.  
  61. - (void)didReceiveMemoryWarning {
  62. [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
  63. // Release anything that's not essential, such as cached data
  64. }
  65.  
  66.  
  67. - (void)dealloc {
  68. // New memory release calls.
  69. [username release];
  70. [password release];
  71. [errorLabel release];
  72. [eventsView release];
  73. [appDel release];
  74.  
  75. [super dealloc];
  76. }
  77.  
  78. @end
Add Comment
Please, Sign In to add comment