Guest User

Untitled

a guest
Aug 12th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.30 KB | None | 0 0
  1. Navigation error crash in pageload
  2. #import "PasswordViewController.h"
  3. #import "PasswordView.h"
  4.  
  5. @interface PasswordViewController ()
  6.  
  7. @property (nonatomic, retain) NSString *status;
  8.  
  9. - (IBAction)cancel:(id)sender;
  10. - (IBAction)setAccount:(id)sender;
  11.  
  12. @end
  13.  
  14. @implementation PasswordViewController
  15.  
  16. @dynamic status;
  17. @synthesize username = m_username,
  18. password = m_password
  19. ;
  20. @dynamic isAccountVerified;
  21.  
  22. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil delegate:(NSObject <PasswordDelegate> *)delegate
  23. {
  24. if (self == [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])
  25. {
  26. // Custom initialization
  27. self.username = @"";
  28. self.password = @"";
  29.  
  30. m_status = @"";
  31. m_delegate = delegate;
  32.  
  33. UIBarButtonItem *buttonT = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancel:)];
  34. self.navigationItem.leftBarButtonItem = buttonT;
  35. [buttonT release];
  36.  
  37. buttonT = [[UIBarButtonItem alloc] initWithTitle:@"Set" style:UIBarButtonItemStyleBordered target:self action:@selector(setAccount:)];
  38. self.navigationItem.rightBarButtonItem = buttonT;
  39. [buttonT release];
  40. }
  41. return self;
  42. }
  43.  
  44. - (void)viewDidLoad
  45. {
  46. [super viewDidLoad];
  47.  
  48. m_fViewLoaded = YES;
  49.  
  50. PasswordView *passwordview = (PasswordView *)self.view;
  51. passwordview.textfieldUsername.text = self.username;
  52. passwordview.textfieldUsername.delegate = self;
  53. passwordview.textfieldPassword.text = self.password;
  54. passwordview.textfieldPassword.delegate = self;
  55. passwordview.labelStatus.text = m_status;
  56. passwordview.labelErrorMsg.text = @"";
  57. passwordview.spinner.hidden = YES;
  58. }
  59.  
  60. - (void)dealloc
  61. {
  62. [super dealloc];
  63. }
  64.  
  65. #pragma mark Actions
  66.  
  67. - (IBAction)cancel:(id)sender
  68. {
  69. [m_delegate cancelSetPassword:self];
  70. }
  71.  
  72. - (IBAction)setAccount:(id)sender
  73. {
  74. m_status = @"Verifying account…";
  75.  
  76. Assert(m_fViewLoaded);
  77. if (m_fViewLoaded)
  78. {
  79. PasswordView *passwordview = (PasswordView *)self.view;
  80. passwordview.spinner.hidden = NO;
  81. [passwordview.spinner startAnimating];
  82.  
  83. self.username = passwordview.textfieldUsername.text;
  84. self.password = passwordview.textfieldPassword.text;
  85. [m_delegate verifyAccount:self username:self.username password:self.password];
  86. }
  87. }
  88.  
  89. #pragma mark Properties
  90.  
  91. - (BOOL)isAccountVerified
  92. {
  93. return m_fAccountVerified;
  94. }
  95.  
  96. - (void)setIsAccountVerified:(BOOL)fVerified
  97. {
  98. m_fAccountVerified = fVerified;
  99. self.status = [NSString stringWithFormat:@"Account login %@.", m_fAccountVerified ? @"succeeded" : @"failed"];
  100.  
  101. if (m_fViewLoaded)
  102. {
  103. PasswordView *passwordview = (PasswordView *)self.view;
  104. [passwordview.spinner stopAnimating];
  105. passwordview.spinner.hidden = YES;
  106. }
  107.  
  108. if (fVerified)
  109. [m_delegate setAccount:self username:self.username password:self.password];
  110. }
  111.  
  112. - (NSString *)status
  113. {
  114. return m_status;
  115. }
  116.  
  117. - (void)setStatus:(NSString *)status
  118. {
  119. if (m_status != status)
  120. [m_status release];
  121. m_status = [status retain];
  122.  
  123. if (m_fViewLoaded)
  124. {
  125. PasswordView *passwordview = (PasswordView *)self.view;
  126. passwordview.labelStatus.text = m_status;
  127. }
  128. }
  129.  
  130. - (void)setError:(NSError *)error
  131. {
  132. if (m_fViewLoaded)
  133. {
  134. PasswordView *passwordview = (PasswordView *)self.view;
  135.  
  136. passwordview.labelErrorMsg.text = error == nil
  137. ? @""
  138. : [NSString stringWithFormat:@"%@ (%d)", [error.userInfo objectForKey:@"error"], error.code];
  139. }
  140. }
  141.  
  142. #import "PasswordViewController.h"
  143. #import "PasswordView.h"
  144. #import "Googledocmainpage.h"
  145.  
  146. @interface PasswordViewController ()
  147.  
  148. @property (nonatomic, retain) NSString *status;
  149.  
  150. - (IBAction)cancel:(id)sender;
  151. - (IBAction)setAccount:(id)sender;
  152.  
  153. @end
  154.  
  155. @implementation PasswordViewController
  156.  
  157. @dynamic status;
  158. @synthesize username = m_username,
  159. password = m_password
  160. ;
  161. @dynamic isAccountVerified;
  162.  
  163. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil delegate:(NSObject <PasswordDelegate> *)delegate
  164. {
  165. if (self == [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])
  166. {
  167. // Custom initialization
  168. self.username = @"";
  169. self.password = @"";
  170.  
  171. m_status = @"";
  172. m_delegate = delegate;
  173.  
  174. UIBarButtonItem *buttonT = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancel:)];
  175. self.navigationItem.leftBarButtonItem = buttonT;
  176. [buttonT release];
  177.  
  178. buttonT = [[UIBarButtonItem alloc] initWithTitle:@"Set" style:UIBarButtonItemStyleBordered target:self action:@selector(setAccount:)];
  179. self.navigationItem.rightBarButtonItem = buttonT;
  180. [buttonT release]; }
  181. return self;
  182. }
  183.  
  184. - (void)viewDidLoad
  185. {
  186. [super viewDidLoad];
  187.  
  188. m_fViewLoaded = YES;
  189.  
  190. PasswordView *passwordview = (PasswordView *)self.view;
  191. passwordview.textfieldUsername.text = self.username;
  192. passwordview.textfieldUsername.delegate = self;
  193. passwordview.textfieldPassword.text = self.password;
  194. passwordview.textfieldPassword.delegate = self;
  195. passwordview.labelStatus.text = m_status;
  196. passwordview.labelErrorMsg.text = @"";
  197. passwordview.spinner.hidden = YES;
  198. }
  199. -(IBAction)_clikcGooglebtnclose:(id)sender
  200. {
  201. [m_delegate cancelSetPassword:self];
  202. [self dismissModalViewControllerAnimated:YES];
  203. }
  204. - (void)dealloc
  205. {
  206. [super dealloc];
  207. }
  208.  
  209. #pragma mark Actions
  210.  
  211. - (IBAction)cancel:(id)sender
  212. {
  213. [m_delegate cancelSetPassword:self];
  214. }
  215.  
  216. - (IBAction)setAccount:(id)sender
  217. {
  218. m_status = @"Verifying account…";
  219.  
  220. Assert(m_fViewLoaded);
  221. if (m_fViewLoaded)
  222. {
  223. PasswordView *passwordview = (PasswordView *)self.view;
  224. passwordview.spinner.hidden = NO;
  225. [passwordview.spinner startAnimating];
  226.  
  227. self.username = passwordview.textfieldUsername.text;
  228. self.password = passwordview.textfieldPassword.text;
  229. [m_delegate verifyAccount:self username:self.username password:self.password];
  230.  
  231.  
  232. }
  233. }
  234.  
  235. #pragma mark Properties
  236.  
  237. - (BOOL)isAccountVerified
  238. {
  239. return m_fAccountVerified;
  240.  
  241.  
  242.  
  243. }
  244.  
  245. - (void)setIsAccountVerified:(BOOL)fVerified
  246. {
  247. m_fAccountVerified = fVerified;
  248. self.status = [NSString stringWithFormat:@"Account login %@.", m_fAccountVerified ? @"succeeded" : @"failed"];
  249.  
  250. if (m_fViewLoaded)
  251. {
  252. PasswordView *passwordview = (PasswordView *)self.view;
  253. [passwordview.spinner stopAnimating];
  254. passwordview.spinner.hidden = YES;
  255.  
  256. }
  257.  
  258. if (fVerified)
  259. [m_delegate setAccount:self username:self.username password:self.password];
  260. // [self dismissModalViewControllerAnimated:YES];
  261.  
  262.  
  263. }
  264.  
  265. - (NSString *)status
  266. {
  267. return m_status;
  268. }
  269.  
  270. - (void)setStatus:(NSString *)status
  271. {
  272. if (m_status != status)
  273. [m_status release];
  274. m_status = [status retain];
  275.  
  276. if (m_fViewLoaded)
  277. {
  278. PasswordView *passwordview = (PasswordView *)self.view;
  279. passwordview.labelStatus.text = m_status;
  280. }
  281. }
  282.  
  283. - (void)setError:(NSError *)error
  284. {
  285. if (m_fViewLoaded)
  286. {
  287. PasswordView *passwordview = (PasswordView *)self.view;
  288.  
  289. passwordview.labelErrorMsg.text = error == nil
  290. ? @""
  291. : [NSString stringWithFormat:@"%@ (%d)", [error.userInfo objectForKey:@"error"], error.code];
  292. }
  293. }
Add Comment
Please, Sign In to add comment