Advertisement
Guest User

Untitled

a guest
Dec 24th, 2015
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.53 KB | None | 0 0
  1. //
  2. // LoginViewController.m
  3. // IronWorldProject
  4. //
  5. // Created by Studio Vision on 23.11.15.
  6. // Copyright © 2015 Studio Vision. All rights reserved.
  7. //
  8.  
  9. #import "LoginViewController.h"
  10. #import "AVFoundation/AVFoundation.h"
  11. #import "EnterModeViewController.h"
  12. #import "MainMenuViewController.h"
  13. #import "ForgotPasswordViewController.h"
  14.  
  15. #import <CommonCrypto/CommonDigest.h>
  16.  
  17. #import "ServerManager.h"
  18.  
  19. #import <Foundation/Foundation.h>
  20. #import <VKSdk/VKSdk.h>
  21.  
  22. #import <FBSDKCoreKit/FBSDKCoreKit.h>
  23. #import <FBSDKLoginKit/FBSDKLoginKit.h>
  24. #import <FBSDKShareKit/FBSDKShareKit.h>
  25. #import <QuartzCore/QuartzCore.h>
  26. #import <AdSupport/AdSupport.h>
  27. #import <CoreMotion/CoreMotion.h>
  28.  
  29. #import "GMDCircleLoader.h"
  30.  
  31. @interface LoginViewController () <UITextFieldDelegate,
  32. VKSdkUIDelegate, VKSdkDelegate>
  33.  
  34.  
  35. @property (weak, nonatomic) IBOutlet UIView *titleContainerView;
  36.  
  37. @property (weak, nonatomic) IBOutlet UITextField *loginTextField;
  38. @property (weak, nonatomic) IBOutlet UITextField *passwordTextField;
  39.  
  40. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *heightLayout;
  41. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *widthLayout;
  42. @property (weak, nonatomic) IBOutlet UIView *containerView;
  43.  
  44. @property (weak, nonatomic) IBOutlet UIScrollView *myScrollView;
  45.  
  46. @property (weak, nonatomic) IBOutlet UIButton *enterButton;
  47. @property (weak, nonatomic) IBOutlet UIButton *forgetPasswordButton;
  48.  
  49. @property (weak, nonatomic) IBOutlet UILabel *titleLabel;
  50.  
  51. @property (weak, nonatomic) UIView * backgroundBlackView;
  52.  
  53. @property (weak, nonatomic) UIView * loadBlackView;
  54.  
  55. @end
  56.  
  57. static NSString * const TOKEN_KEY = @"CNYwWzVi7a9BDaKGQOf8";
  58. static NSArray * SCOPE = nil;
  59.  
  60. static NSInteger loadBlackViewTag = 99;
  61.  
  62. static NSInteger iphoneLimit = 414;
  63.  
  64. static NSInteger iphone5Height = 568;
  65.  
  66. @implementation LoginViewController
  67.  
  68. - (void)viewDidLoad {
  69.  
  70. [super viewDidLoad];
  71.  
  72.  
  73. NSInteger textFieldFontSize = 14;
  74. NSInteger titleLabelFontSize = 18;
  75. NSInteger buttonFontSize = 15;
  76. NSInteger passwordButton = 16;
  77.  
  78. if (self.view.frame.size.width > iphoneLimit) {
  79.  
  80. textFieldFontSize = 17;
  81. titleLabelFontSize = 23;
  82. buttonFontSize = 20;
  83. passwordButton = 19;
  84. }
  85.  
  86. [self.loginTextField setFont:[UIFont fontWithName:@"Roboto-Medium"
  87. size:textFieldFontSize]];
  88.  
  89. [self.titleLabel setFont:[UIFont fontWithName:@"Roboto-Medium"
  90. size:titleLabelFontSize]];
  91.  
  92. [self.enterButton.titleLabel setFont:[UIFont fontWithName:@"Roboto-Medium"
  93. size:buttonFontSize]];
  94.  
  95. [self.forgetPasswordButton.titleLabel setFont:[UIFont fontWithName:@"Roboto-Medium"
  96. size:passwordButton]];
  97.  
  98. [self.loginTextField setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"];
  99. [self.passwordTextField setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"];
  100.  
  101.  
  102. self.loginTextField.layer.borderColor = [UIColor redColor].CGColor;
  103. self.loginTextField.layer.borderWidth = 0;
  104. self.passwordTextField.layer.borderColor = [UIColor redColor].CGColor;
  105. self.passwordTextField.layer.borderWidth = 0;
  106.  
  107. self.loginTextField.delegate = self;
  108. self.passwordTextField.delegate = self;
  109.  
  110.  
  111. // scroll
  112. //self.myScrollView.pagingEnabled = YES;
  113. //self.automaticallyAdjustsScrollViewInsets = NO;
  114.  
  115. self.heightLayout.constant = self.view.frame.size.height - self.titleContainerView.frame.size.height;
  116. self.widthLayout.constant = self.view.frame.size.width;
  117.  
  118.  
  119. UIView * loadBlackView = [[UIView alloc]initWithFrame:self.view.frame];
  120. loadBlackView.backgroundColor = [UIColor blackColor];
  121. loadBlackView.alpha = 0;
  122. loadBlackView.tag = loadBlackViewTag;
  123. [self.view addSubview:loadBlackView];
  124. self.loadBlackView = loadBlackView;
  125.  
  126.  
  127. // VK
  128. SCOPE = @[VK_PER_FRIENDS, VK_PER_WALL, VK_PER_AUDIO, VK_PER_PHOTOS, VK_PER_NOHTTPS, VK_PER_EMAIL, VK_PER_MESSAGES];
  129. [[VKSdk initializeWithAppId:@"5184196"] registerDelegate:self];
  130. [[VKSdk instance] setUiDelegate:self];
  131.  
  132.  
  133.  
  134. for (UIView * subView in self.view.subviews)
  135. subView.alpha = 0;
  136. }
  137.  
  138. - (void)viewDidAppear:(BOOL)animated {
  139.  
  140. [super viewDidAppear:animated];
  141. [UIView animateWithDuration:0.7f animations:^{
  142.  
  143. for (UIView * subView in self.view.subviews) {
  144. if (subView.tag != loadBlackViewTag)
  145. subView.alpha = 1;
  146. }
  147.  
  148. } completion:^(BOOL finished) {
  149.  
  150. //self.loadBlackView.alpha = 0.6;
  151. //[GMDCircleLoader setOnView:self.view withTitle:@"Loading " animated:YES];
  152. }];
  153. }
  154.  
  155. #pragma mark -Message
  156.  
  157. - (void) showMessageWithTitle:(NSString *) message {
  158.  
  159. UIView * backgroundBlackView = [[UIView alloc]initWithFrame:self.view.frame];
  160. backgroundBlackView.backgroundColor = [UIColor blackColor];
  161. backgroundBlackView.alpha = 0;
  162. [self.view addSubview:backgroundBlackView];
  163. self.backgroundBlackView = backgroundBlackView;
  164.  
  165.  
  166. UITapGestureRecognizer *singleFingerTap =
  167. [[UITapGestureRecognizer alloc] initWithTarget:self
  168. action:@selector(hideMessage:)];
  169. [backgroundBlackView addGestureRecognizer:singleFingerTap];
  170.  
  171.  
  172. CGFloat labelHeight = [self getTextHeight:message];
  173. UILabel * messageLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 50, self.view.frame.size.width, labelHeight)];
  174. messageLabel.text = message;
  175. messageLabel.font = [UIFont fontWithName:@"Roboto-Medium" size:15];
  176. messageLabel.textAlignment = UIBaselineAdjustmentAlignCenters;
  177. messageLabel.numberOfLines = 0;
  178. messageLabel.textColor = [UIColor whiteColor];
  179. messageLabel.center = backgroundBlackView.center;
  180. [backgroundBlackView addSubview:messageLabel];
  181.  
  182.  
  183. UIImageView * messageIconImage = [[UIImageView alloc]initWithFrame:CGRectMake(1, 1, 50, 50)];
  184. messageIconImage.image = [UIImage imageNamed:@"userAvatar.png"];
  185. messageIconImage.center = CGPointMake(backgroundBlackView.frame.size.width / 2, messageLabel.frame.origin.y - 25);
  186. [self.backgroundBlackView addSubview:messageIconImage];
  187.  
  188. UILabel * okLabel = [[UILabel alloc]initWithFrame:CGRectMake(-1, messageLabel.frame.origin.y + labelHeight - 15, self.view.frame.size.width + 2, 60)];
  189. okLabel.textColor = [UIColor whiteColor];
  190. okLabel.textAlignment = UIBaselineAdjustmentAlignCenters;
  191. okLabel.text = @"Ok";
  192. okLabel.font = [UIFont fontWithName:@"Roboto-Medium" size:20];
  193. okLabel.layer.borderColor = [UIColor whiteColor].CGColor;
  194. okLabel.layer.borderWidth = 1;
  195. [backgroundBlackView addSubview:okLabel];
  196.  
  197. [UIView animateWithDuration:0.4 animations:^{
  198.  
  199. backgroundBlackView.alpha = 0.8;
  200.  
  201. } completion:^(BOOL finished) {
  202.  
  203. }];
  204.  
  205. }
  206.  
  207. - (CGFloat) getTextHeight:(NSString*) text {
  208.  
  209. CGFloat offset = 5.0;
  210. //UIFont * font = [UIFont systemFontOfSize:15.f];
  211. UIFont * font = [UIFont fontWithName:@"Roboto-Medium" size:15];
  212.  
  213. NSShadow * shadow = [[NSShadow alloc] init];
  214. shadow.shadowOffset = CGSizeMake(0, -1);
  215. shadow.shadowBlurRadius = 0.5;
  216.  
  217. NSMutableParagraphStyle * paragraph = [[NSMutableParagraphStyle alloc] init];
  218. [paragraph setLineBreakMode:NSLineBreakByWordWrapping];
  219. [paragraph setAlignment:NSTextAlignmentCenter];
  220.  
  221. NSDictionary * attributes =
  222. [NSDictionary dictionaryWithObjectsAndKeys:
  223. font, NSFontAttributeName,
  224. paragraph, NSParagraphStyleAttributeName,
  225. shadow, NSShadowAttributeName, nil];
  226.  
  227. CGRect rect = [text boundingRectWithSize:CGSizeMake(self.view.frame.size.width - 2 * offset, CGFLOAT_MAX)
  228. options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading
  229. attributes:attributes
  230. context:nil];
  231.  
  232. return CGRectGetHeight(rect) + 2 * offset;
  233. }
  234.  
  235.  
  236. - (void)hideMessage:(UITapGestureRecognizer *)recognizer {
  237.  
  238. [UIView animateWithDuration:0.2 animations:^{
  239.  
  240. self.backgroundBlackView.alpha = 0;
  241. } completion:^(BOOL finished) {
  242.  
  243.  
  244. }];
  245. }
  246.  
  247.  
  248. - (void)fieldValidation {
  249.  
  250. if ([self.loginTextField.text isEqualToString:@""])
  251. self.loginTextField.layer.borderWidth = 1;
  252. else
  253. self.loginTextField.layer.borderWidth = 0;
  254.  
  255. if ([self.passwordTextField.text isEqualToString:@""])
  256. self.passwordTextField.layer.borderWidth = 1;
  257. else
  258. self.passwordTextField.layer.borderWidth = 0;
  259. }
  260.  
  261.  
  262. #pragma mark -UITextFieldDelegate
  263.  
  264. - (BOOL)textFieldShouldReturn:(UITextField *)textField {
  265.  
  266. if (textField == self.loginTextField) {
  267.  
  268. [self.passwordTextField becomeFirstResponder];
  269. } else {
  270.  
  271. [self actionEnter:nil];
  272. }
  273.  
  274. return YES;
  275. }
  276.  
  277. - (void)textFieldDidBeginEditing:(UITextField *)textField {
  278.  
  279.  
  280. textField.layer.borderWidth = 0;
  281.  
  282. self.myScrollView.scrollEnabled = YES;
  283. if (self.view.frame.size.height <= iphone5Height) {
  284.  
  285. self.heightLayout.constant = 580;
  286. NSInteger scrollPos = 80;
  287.  
  288. if (self.view.frame.size.height == 480) {
  289.  
  290. scrollPos = 150;
  291. }
  292.  
  293.  
  294. [self.myScrollView setContentOffset:CGPointMake(self.myScrollView.frame.origin.x, scrollPos)
  295. animated:YES];
  296. }
  297. }
  298.  
  299. - (void)textFieldDidEndEditing:(UITextField *)textField {
  300.  
  301. if (self.view.frame.size.height <= iphone5Height) {
  302.  
  303.  
  304. [self.myScrollView setContentOffset:CGPointMake(self.myScrollView.frame.origin.x, 0)
  305. animated:YES];
  306.  
  307. self.myScrollView.scrollEnabled = NO;
  308. }
  309. }
  310.  
  311. #pragma mark -VKSdkUIDelegate
  312.  
  313. - (void)vkSdkShouldPresentViewController:(UIViewController *)controller {
  314. [self.navigationController.topViewController presentViewController:controller animated:YES completion:nil];
  315. }
  316.  
  317. - (void)vkSdkNeedCaptchaEnter:(VKError *)captchaError {
  318. VKCaptchaViewController *vc = [VKCaptchaViewController captchaControllerWithError:captchaError];
  319. [vc presentIn:self.navigationController.topViewController];
  320. //[self presentViewController:vc animated:YES completion:nil];
  321. }
  322.  
  323.  
  324. #pragma mark -VKSdkDelegate
  325.  
  326. - (void)vkSdkTokenHasExpired:(VKAccessToken *)expiredToken {
  327. [self actionLogVK:nil];
  328. }
  329.  
  330. - (void)vkSdkUserAuthorizationFailed {
  331.  
  332. [self dismissViewControllerAnimated:YES completion:nil];
  333. }
  334.  
  335.  
  336. - (void)vkSdkAccessAuthorizationFinishedWithResult:(VKAuthorizationResult *)result {
  337. if (result.token) {
  338.  
  339. [self.view endEditing:YES];
  340. [self dismissViewControllerAnimated:YES completion:nil];
  341.  
  342. NSLog(@"_________________________________________");
  343. NSLog(@"Token: %@",result.token.accessToken);
  344. NSLog(@"id: %@",result.user.id);
  345. NSLog(@"first_name: %@",result.user.first_name);
  346. NSLog(@"last_name: %@",result.user.last_name);
  347. NSLog(@"sex: %@",result.user.sex);
  348. NSLog(@"bdate: %@",result.user.bdate);
  349. NSLog(@"photo_100: %@",result.user.photo_100);
  350. NSLog(@"email: %@",result.token.email);
  351.  
  352.  
  353. if (result.user.first_name && result.user.last_name &&
  354. result.user.sex && result.user.bdate && result.user.photo_100) {
  355.  
  356. NSString * sexStr = @"1";
  357. if (result.user.sex == 0)
  358. sexStr = @"0";
  359.  
  360. [self saveDataAboutUserWithFirstName:result.user.first_name
  361. lastName:result.user.last_name
  362. userEmail:@"vkEmail"
  363. userGender:sexStr
  364. userPassword:@"vkPassword"
  365. userBirthdaty:result.user.bdate
  366. userAvatar:result.user.photo_100];
  367. } else {
  368.  
  369. [self showMessageWithTitle:@"Нету всех данных\n"];
  370. }
  371.  
  372.  
  373. } else if (result.error) {
  374.  
  375. NSLog(@"%@",result.error);
  376. }
  377. }
  378.  
  379.  
  380. #pragma mark -Server
  381.  
  382. - (void)loginUserWithEmail:(NSString *)email andPassword:(NSString *)password {
  383.  
  384. NSString * md5Password = [self generateMD5:password];
  385.  
  386. self.loadBlackView.alpha = 0.6;
  387. [GMDCircleLoader setOnView:self.view withTitle:@"Loading..." animated:YES];
  388.  
  389. [[ServerManager sharedManager]loginUserWithEmail:self.loginTextField.text password:md5Password onSuccess:^(id resultJSON) {
  390.  
  391. NSString * requestStatus = resultJSON[@"status"];
  392.  
  393.  
  394. if ([requestStatus intValue] == SUCCESS) {
  395.  
  396. for (UIView * subView in self.view.subviews)
  397. [subView removeFromSuperview];
  398.  
  399. MainMenuViewController * vc = [self.storyboard instantiateViewControllerWithIdentifier:@"MainMenuViewController"];
  400. [self addChildViewController:vc];
  401. [self.view addSubview:vc.view];
  402. [vc didMoveToParentViewController:self];
  403. vc.view.frame = CGRectMake(0,
  404. self.view.frame.size.height - vc.view.frame.size.height,
  405. vc.view.frame.size.width,
  406. vc.view.frame.size.height);
  407.  
  408. } else if ([requestStatus intValue] == EMAIL_NOT_FOUND) {
  409.  
  410. [self showMessageWithTitle:@"Can't find this email\n"];
  411. } else if ([requestStatus intValue] == WRONG_PASSWORD) {
  412.  
  413. [self showMessageWithTitle:@"Wrong password\n"];
  414. } else {
  415.  
  416. [self showMessageWithTitle:@"Opp's something going wrong\n"];
  417. }
  418.  
  419.  
  420.  
  421.  
  422. self.loadBlackView.alpha = 0;
  423. [GMDCircleLoader hideFromView:self.view animated:YES];
  424.  
  425. } onFailure:^(NSError *error) {
  426.  
  427. if (error.code == CONNECTION_ERROR) {
  428. [self showMessageWithTitle:@"You are offline\n"];
  429. } else
  430. [self showMessageWithTitle:@"Opp's something going wrong\n"];
  431.  
  432. self.loadBlackView.alpha = 0;
  433. [GMDCircleLoader hideFromView:self.view animated:YES];
  434. }];
  435. }
  436.  
  437. - (NSString *)generateMD5:(NSString *)input {
  438.  
  439. const char * cStr = [input UTF8String];
  440. unsigned char digest[CC_MD5_DIGEST_LENGTH];
  441. CC_MD5( cStr, (CC_LONG)strlen(cStr), digest);
  442.  
  443. NSMutableString * output = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2];
  444.  
  445. for(NSInteger i = 0; i < CC_MD5_DIGEST_LENGTH; i++)
  446. [output appendFormat:@"%02x", digest[i]];
  447.  
  448. return output;
  449. }
  450.  
  451.  
  452. #pragma mark -Action
  453.  
  454. - (IBAction)actionBack:(id)sender {
  455.  
  456. [self.view endEditing:YES];
  457. for (UIView * subView in self.view.subviews)
  458. [subView removeFromSuperview];
  459.  
  460. EnterModeViewController * vc = [self.storyboard instantiateViewControllerWithIdentifier:@"EnterModeViewController"];
  461. [self addChildViewController:vc];
  462. [self.view addSubview:vc.view];
  463. [vc didMoveToParentViewController:self];
  464. vc.view.frame = CGRectMake(0,
  465. self.view.frame.size.height - vc.view.frame.size.height,
  466. vc.view.frame.size.width,
  467. vc.view.frame.size.height);
  468. }
  469.  
  470. - (IBAction)actionEnter:(id)sender {
  471.  
  472. [self.view endEditing:YES];
  473.  
  474. [self fieldValidation];
  475. if ([self.loginTextField.text isEqualToString:@""] || [self.passwordTextField.text isEqualToString:@""]) {
  476.  
  477.  
  478. [self showMessageWithTitle:@"enter all fields\n"];
  479. } else {
  480.  
  481. [self loginUserWithEmail:self.loginTextField.text andPassword:self.passwordTextField.text];
  482. }
  483. }
  484.  
  485.  
  486. - (IBAction)actionForgotPassword:(id)sender {
  487.  
  488.  
  489. [self.view endEditing:YES];
  490. for (UIView * subView in self.view.subviews)
  491. [subView removeFromSuperview];
  492.  
  493. ForgotPasswordViewController * vc = [self.storyboard instantiateViewControllerWithIdentifier:@"ForgotPasswordViewController"];
  494. [self addChildViewController:vc];
  495. [self.view addSubview:vc.view];
  496. [vc didMoveToParentViewController:self];
  497. vc.view.frame = CGRectMake(0,
  498. self.view.frame.size.height - vc.view.frame.size.height,
  499. vc.view.frame.size.width,
  500. vc.view.frame.size.height);
  501. }
  502.  
  503. #pragma mark -SocialAction
  504.  
  505. - (IBAction)actionLogVK:(id)sender {
  506.  
  507.  
  508. [VKSdk forceLogout];
  509.  
  510. //[VKSdk authorize:SCOPE];
  511. VKShareDialogController *shareDialog = [VKShareDialogController new];
  512. [shareDialog setCompletionHandler:^(VKShareDialogController *dialog, VKShareDialogControllerResult result) {
  513. [self dismissViewControllerAnimated:YES completion:nil];
  514. }];
  515. [self presentViewController:shareDialog animated:YES completion:nil];
  516. }
  517.  
  518.  
  519. - (IBAction)actionLogFB:(id)sender {
  520.  
  521. //[FBSDKAccessToken setCurrentAccessToken:nil];
  522.  
  523. FBSDKLoginManager * login = [[FBSDKLoginManager alloc] init];
  524. if ([FBSDKAccessToken currentAccessToken]) {
  525.  
  526. [self getUserInfoFromFB];
  527.  
  528. } else
  529. {
  530. [login logInWithReadPermissions:@[@"email", @"user_birthday"] fromViewController:self handler:^(FBSDKLoginManagerLoginResult *result, NSError *error)
  531. {
  532. if (error) {
  533.  
  534. NSLog(@"Login error: %@",error);
  535. } else {
  536.  
  537. NSLog(@"Login Success");
  538. [self getUserInfoFromFB];
  539. }
  540. }];
  541. }
  542. }
  543.  
  544. - (void)getUserInfoFromFB
  545. {
  546. if ([FBSDKAccessToken currentAccessToken]) {
  547.  
  548. NSLog(@"Token is available : %@",[[FBSDKAccessToken currentAccessToken]tokenString]);
  549.  
  550. NSDictionary * params = @{@"fields": @"id, name, email, last_name, first_name, birthday,gender, picture"};
  551.  
  552.  
  553. self.loadBlackView.alpha = 0.6;
  554. [GMDCircleLoader setOnView:self.view withTitle:@"Loading..." animated:YES];
  555.  
  556. [[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:params] startWithCompletionHandler:
  557. ^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
  558.  
  559. if (error) {
  560.  
  561. [self showMessageWithTitle:@"Error, while get fb info\n"];
  562. self.loadBlackView.alpha = 0;
  563. [GMDCircleLoader hideFromView:self.view animated:YES];
  564. NSLog(@"FB user info error: %@",error);
  565.  
  566. } else {
  567.  
  568. NSLog(@"FB user info: %@",result);
  569.  
  570.  
  571. NSDictionary * userInfoDict = result;
  572.  
  573. NSDictionary * pictureData = userInfoDict[@"picture"];
  574. NSDictionary * dataFromPictureData = pictureData[@"data"];
  575. NSString * fbAvatarURLStr = dataFromPictureData[@"url"];
  576.  
  577. NSString * genderStr = @"1";
  578.  
  579. if ([userInfoDict[@"gender"] isEqualToString:@"female"])
  580. genderStr = @"0";
  581.  
  582.  
  583.  
  584.  
  585. [[ServerManager sharedManager]authoSocialNetworkWithFirstName:userInfoDict[@"first_name"]
  586. lastName:userInfoDict[@"last_name"]
  587. email:userInfoDict[@"email"]
  588. gender:genderStr
  589. birthday:userInfoDict[@"birthday"]
  590. typeOfSN:@"Facebook"
  591. userID:userInfoDict[@"id"]
  592. avatarURL:fbAvatarURLStr
  593. onSuccess:^(id resultJSON) {
  594.  
  595.  
  596. self.loadBlackView.alpha = 0;
  597. [GMDCircleLoader hideFromView:self.view animated:YES];
  598.  
  599. } onFailure:^(NSError *error) {
  600.  
  601. self.loadBlackView.alpha = 0;
  602. [GMDCircleLoader hideFromView:self.view animated:YES];
  603. }];
  604.  
  605.  
  606.  
  607. // [self saveDataAboutUserWithFirstName:userInfoDict[@"first_name"]
  608. // lastName:userInfoDict[@"last_name"]
  609. // userEmail:userInfoDict[@"email"]
  610. // userGender:genderStr
  611. // userPassword:@"fbPassword"
  612. // userBirthdaty:userInfoDict[@"birthday"]
  613. // userAvatar:fbAvatarURLStr];
  614. }
  615. }];
  616. }
  617. }
  618.  
  619. - (void)saveDataAboutUserWithFirstName:(NSString *)firstName
  620. lastName:(NSString *)lastName
  621. userEmail:(NSString *)email
  622. userGender:(NSString *)gender
  623. userPassword:(NSString *) password
  624. userBirthdaty:(NSString *)birthday
  625. userAvatar:(NSString *)avatar {
  626.  
  627. NSUserDefaults * userDef = [NSUserDefaults standardUserDefaults];
  628. [userDef setObject:firstName forKey:@"firstNameKey"];
  629. [userDef setObject:lastName forKey:@"lastNameKey"];
  630. [userDef setObject:email forKey:@"emailKey"];
  631. [userDef setObject:gender forKey:@"genderKey"];
  632. [userDef setObject:password forKey:@"passwordKey"];
  633. [userDef setObject:birthday forKey:@"birthdayKey"];
  634. [userDef setObject:avatar forKey:@"avatarKey"];
  635. [userDef synchronize];
  636. }
  637.  
  638.  
  639.  
  640.  
  641. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement