Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Navigation error crash in pageload
- #import "PasswordViewController.h"
- #import "PasswordView.h"
- @interface PasswordViewController ()
- @property (nonatomic, retain) NSString *status;
- - (IBAction)cancel:(id)sender;
- - (IBAction)setAccount:(id)sender;
- @end
- @implementation PasswordViewController
- @dynamic status;
- @synthesize username = m_username,
- password = m_password
- ;
- @dynamic isAccountVerified;
- - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil delegate:(NSObject <PasswordDelegate> *)delegate
- {
- if (self == [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])
- {
- // Custom initialization
- self.username = @"";
- self.password = @"";
- m_status = @"";
- m_delegate = delegate;
- UIBarButtonItem *buttonT = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancel:)];
- self.navigationItem.leftBarButtonItem = buttonT;
- [buttonT release];
- buttonT = [[UIBarButtonItem alloc] initWithTitle:@"Set" style:UIBarButtonItemStyleBordered target:self action:@selector(setAccount:)];
- self.navigationItem.rightBarButtonItem = buttonT;
- [buttonT release];
- }
- return self;
- }
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- m_fViewLoaded = YES;
- PasswordView *passwordview = (PasswordView *)self.view;
- passwordview.textfieldUsername.text = self.username;
- passwordview.textfieldUsername.delegate = self;
- passwordview.textfieldPassword.text = self.password;
- passwordview.textfieldPassword.delegate = self;
- passwordview.labelStatus.text = m_status;
- passwordview.labelErrorMsg.text = @"";
- passwordview.spinner.hidden = YES;
- }
- - (void)dealloc
- {
- [super dealloc];
- }
- #pragma mark Actions
- - (IBAction)cancel:(id)sender
- {
- [m_delegate cancelSetPassword:self];
- }
- - (IBAction)setAccount:(id)sender
- {
- m_status = @"Verifying account…";
- Assert(m_fViewLoaded);
- if (m_fViewLoaded)
- {
- PasswordView *passwordview = (PasswordView *)self.view;
- passwordview.spinner.hidden = NO;
- [passwordview.spinner startAnimating];
- self.username = passwordview.textfieldUsername.text;
- self.password = passwordview.textfieldPassword.text;
- [m_delegate verifyAccount:self username:self.username password:self.password];
- }
- }
- #pragma mark Properties
- - (BOOL)isAccountVerified
- {
- return m_fAccountVerified;
- }
- - (void)setIsAccountVerified:(BOOL)fVerified
- {
- m_fAccountVerified = fVerified;
- self.status = [NSString stringWithFormat:@"Account login %@.", m_fAccountVerified ? @"succeeded" : @"failed"];
- if (m_fViewLoaded)
- {
- PasswordView *passwordview = (PasswordView *)self.view;
- [passwordview.spinner stopAnimating];
- passwordview.spinner.hidden = YES;
- }
- if (fVerified)
- [m_delegate setAccount:self username:self.username password:self.password];
- }
- - (NSString *)status
- {
- return m_status;
- }
- - (void)setStatus:(NSString *)status
- {
- if (m_status != status)
- [m_status release];
- m_status = [status retain];
- if (m_fViewLoaded)
- {
- PasswordView *passwordview = (PasswordView *)self.view;
- passwordview.labelStatus.text = m_status;
- }
- }
- - (void)setError:(NSError *)error
- {
- if (m_fViewLoaded)
- {
- PasswordView *passwordview = (PasswordView *)self.view;
- passwordview.labelErrorMsg.text = error == nil
- ? @""
- : [NSString stringWithFormat:@"%@ (%d)", [error.userInfo objectForKey:@"error"], error.code];
- }
- }
- #import "PasswordViewController.h"
- #import "PasswordView.h"
- #import "Googledocmainpage.h"
- @interface PasswordViewController ()
- @property (nonatomic, retain) NSString *status;
- - (IBAction)cancel:(id)sender;
- - (IBAction)setAccount:(id)sender;
- @end
- @implementation PasswordViewController
- @dynamic status;
- @synthesize username = m_username,
- password = m_password
- ;
- @dynamic isAccountVerified;
- - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil delegate:(NSObject <PasswordDelegate> *)delegate
- {
- if (self == [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])
- {
- // Custom initialization
- self.username = @"";
- self.password = @"";
- m_status = @"";
- m_delegate = delegate;
- UIBarButtonItem *buttonT = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancel:)];
- self.navigationItem.leftBarButtonItem = buttonT;
- [buttonT release];
- buttonT = [[UIBarButtonItem alloc] initWithTitle:@"Set" style:UIBarButtonItemStyleBordered target:self action:@selector(setAccount:)];
- self.navigationItem.rightBarButtonItem = buttonT;
- [buttonT release]; }
- return self;
- }
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- m_fViewLoaded = YES;
- PasswordView *passwordview = (PasswordView *)self.view;
- passwordview.textfieldUsername.text = self.username;
- passwordview.textfieldUsername.delegate = self;
- passwordview.textfieldPassword.text = self.password;
- passwordview.textfieldPassword.delegate = self;
- passwordview.labelStatus.text = m_status;
- passwordview.labelErrorMsg.text = @"";
- passwordview.spinner.hidden = YES;
- }
- -(IBAction)_clikcGooglebtnclose:(id)sender
- {
- [m_delegate cancelSetPassword:self];
- [self dismissModalViewControllerAnimated:YES];
- }
- - (void)dealloc
- {
- [super dealloc];
- }
- #pragma mark Actions
- - (IBAction)cancel:(id)sender
- {
- [m_delegate cancelSetPassword:self];
- }
- - (IBAction)setAccount:(id)sender
- {
- m_status = @"Verifying account…";
- Assert(m_fViewLoaded);
- if (m_fViewLoaded)
- {
- PasswordView *passwordview = (PasswordView *)self.view;
- passwordview.spinner.hidden = NO;
- [passwordview.spinner startAnimating];
- self.username = passwordview.textfieldUsername.text;
- self.password = passwordview.textfieldPassword.text;
- [m_delegate verifyAccount:self username:self.username password:self.password];
- }
- }
- #pragma mark Properties
- - (BOOL)isAccountVerified
- {
- return m_fAccountVerified;
- }
- - (void)setIsAccountVerified:(BOOL)fVerified
- {
- m_fAccountVerified = fVerified;
- self.status = [NSString stringWithFormat:@"Account login %@.", m_fAccountVerified ? @"succeeded" : @"failed"];
- if (m_fViewLoaded)
- {
- PasswordView *passwordview = (PasswordView *)self.view;
- [passwordview.spinner stopAnimating];
- passwordview.spinner.hidden = YES;
- }
- if (fVerified)
- [m_delegate setAccount:self username:self.username password:self.password];
- // [self dismissModalViewControllerAnimated:YES];
- }
- - (NSString *)status
- {
- return m_status;
- }
- - (void)setStatus:(NSString *)status
- {
- if (m_status != status)
- [m_status release];
- m_status = [status retain];
- if (m_fViewLoaded)
- {
- PasswordView *passwordview = (PasswordView *)self.view;
- passwordview.labelStatus.text = m_status;
- }
- }
- - (void)setError:(NSError *)error
- {
- if (m_fViewLoaded)
- {
- PasswordView *passwordview = (PasswordView *)self.view;
- passwordview.labelErrorMsg.text = error == nil
- ? @""
- : [NSString stringWithFormat:@"%@ (%d)", [error.userInfo objectForKey:@"error"], error.code];
- }
- }
Add Comment
Please, Sign In to add comment