ViewController.m 1.51 KB
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
//
// ViewController.m
// TwitterKitExample
//
// Created by DongSoo Lee on 2015. 12. 8..
// Copyright © 2015년 DongSoo Lee. All rights reserved.
//

#import "ViewController.h"
#import <TwitterKit/TwitterKit.h>
#import "TWListViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.title = @"트위터 로그인";

__weak typeof(self) wself = self;
TWTRLogInButton *loginButton = [TWTRLogInButton buttonWithLogInCompletion:^(TWTRSession * _Nullable session, NSError * _Nullable error) {
if (session) {
NSString *message = [NSString stringWithFormat:@"@%@ logged in! (%@)", [session userName], [session userID]];

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Logged in!" message:message delegate:wself cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
} else {
NSLog(@"Login error: %@", [error localizedDescription]);
}
}];

loginButton.center = self.view.center;
[self.view addSubview:loginButton];
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
TWListViewController *vc = [[TWListViewController alloc] init];
[self.navigationController pushViewController:vc animated:NO];
}

@end