Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // SignInViewController.m
- // mtracker
- //
- // Created by Temitope Faro on 7/21/11.
- // Copyright 2011 Sleek Computers. All rights reserved.
- #import "SignInViewController.h"
- #import "SFHttpRequestDispatcher.h"
- #import "NSURLConnection-block.h"
- #import "User.h"
- #import "JSONKit.h"
- #import "Util.h"
- #import "settings.h"
- @implementation SignInViewController
- @synthesize mobileNumber;
- @synthesize password;
- - (IBAction) signInUser:(id) sender{
- [self hideKeyboard:nil];
- SFHttpRequestDispatcher *dispatcher = [Util dispatcherForIsActivatedWithMobileNumber:mobileNumber.text
- password:password.text];
- [NSURLConnection asyncRequest:[dispatcher doGetOrPost]
- success:^(NSData *data, NSURLResponse *response) {
- NSDictionary *jsonDictionary = [data objectFromJSONData];
- NSNumber *success = (NSNumber *) [jsonDictionary objectForKey:@"activated"] ;
- NSLog(@"activated: %d", [success boolValue]);
- if([success boolValue] == true){
- UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Sign In Alert"
- message:@"Sign In Successful"
- delegate:nil cancelButtonTitle:@"Dismiss"
- otherButtonTitles:nil];
- [alertView show];
- //not sure of the below line
- [self dismissModalViewControllerAnimated:YES];
- [alertView release];
- }else {
- UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Sign In Alert"
- message:@"Sign in Unsuccessful"
- delegate:nil cancelButtonTitle:@"Dismiss"
- otherButtonTitles:nil];
- [alertView show];
- [alertView release];
- }
- }
- failure:^(NSData *data, NSError *error){
- NSLog(@"XXError! %@",[error localizedDescription]);
- UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error - Signing in"
- message:[error localizedDescription]
- delegate:nil cancelButtonTitle:@"Dismiss"
- otherButtonTitles:nil];
- [alertView show];
- [alertView release];
- }
- ];
- }
- - (IBAction) showRegisterView:(id) sender{
- [self hideKeyboard:nil];
- UIAlertView *alertView = [[UIAlertView alloc] initWithTitle: @"Register Alert"
- message:@"You Clicked on Register"
- delegate:nil cancelButtonTitle:@"Dismiss"
- otherButtonTitles:nil];
- [alertView show];
- [alertView release];
- }
- - (IBAction) hideKeyboard: (id) sender{
- [mobileNumber resignFirstResponder];
- [password resignFirstResponder];
- }
- // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- /*
- - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
- self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
- if (self) {
- // Custom initialization.
- }
- return self;
- }
- */
- /*
- // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- - (void)viewDidLoad {
- [super viewDidLoad];
- }
- */
- /*
- // Override to allow orientations other than the default portrait orientation.
- - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
- // Return YES for supported orientations.
- return (interfaceOrientation == UIInterfaceOrientationPortrait);
- }
- */
- - (void)didReceiveMemoryWarning {
- // Releases the view if it doesn't have a superview.
- [super didReceiveMemoryWarning];
- // Release any cached data, images, etc. that aren't in use.
- }
- - (void)viewDidUnload {
- [super viewDidUnload];
- // Release any retained subviews of the main view.
- // e.g. self.myOutlet = nil;
- }
- - (void)dealloc {
- [mobileNumber release];
- [password release];
- [super dealloc];
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement