Permalink
Browse files

first commit

  • Loading branch information...
1 parent 3a93fbd commit 3f0b7bff92209b06ab9cc7e3fa4218387b5f780d @cutmail committed Feb 16, 2012
@@ -13,31 +13,34 @@
6865AA9614ECC2CF00240660 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6865AA9414ECC2CF00240660 /* InfoPlist.strings */; };
6865AA9814ECC2CF00240660 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 6865AA9714ECC2CF00240660 /* main.m */; };
6865AA9C14ECC2CF00240660 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6865AA9B14ECC2CF00240660 /* AppDelegate.m */; };
- 6865AA9F14ECC2CF00240660 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6865AA9E14ECC2CF00240660 /* ViewController.m */; };
- 6865AAA214ECC2CF00240660 /* ViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6865AAA014ECC2CF00240660 /* ViewController.xib */; };
+ 6865AA9F14ECC2CF00240660 /* AccountsListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6865AA9E14ECC2CF00240660 /* AccountsListViewController.m */; };
+ 6865AAA214ECC2CF00240660 /* AccountsListViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6865AAA014ECC2CF00240660 /* AccountsListViewController.xib */; };
+ 6865AAA914ECC34F00240660 /* Accounts.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6865AAA814ECC34F00240660 /* Accounts.framework */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
6865AA8714ECC2CF00240660 /* TWAccountList.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TWAccountList.app; sourceTree = BUILT_PRODUCTS_DIR; };
6865AA8B14ECC2CF00240660 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
6865AA8D14ECC2CF00240660 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
6865AA8F14ECC2CF00240660 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
- 6865AA9314ECC2CF00240660 /* TWAccountList-Info.plist */ = {isa = PBXFileReference; path = "TWAccountList-Info.plist"; sourceTree = "<group>"; };
+ 6865AA9314ECC2CF00240660 /* TWAccountList-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "TWAccountList-Info.plist"; sourceTree = "<group>"; };
6865AA9514ECC2CF00240660 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
6865AA9714ECC2CF00240660 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
- 6865AA9914ECC2CF00240660 /* TWAccountList-Prefix.pch */ = {isa = PBXFileReference; path = "TWAccountList-Prefix.pch"; sourceTree = "<group>"; };
- 6865AA9A14ECC2CF00240660 /* AppDelegate.h */ = {isa = PBXFileReference; path = AppDelegate.h; sourceTree = "<group>"; };
+ 6865AA9914ECC2CF00240660 /* TWAccountList-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "TWAccountList-Prefix.pch"; sourceTree = "<group>"; };
+ 6865AA9A14ECC2CF00240660 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
6865AA9B14ECC2CF00240660 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
- 6865AA9D14ECC2CF00240660 /* ViewController.h */ = {isa = PBXFileReference; path = ViewController.h; sourceTree = "<group>"; };
- 6865AA9E14ECC2CF00240660 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
- 6865AAA114ECC2CF00240660 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/ViewController.xib; sourceTree = "<group>"; };
+ 6865AA9D14ECC2CF00240660 /* AccountsListViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AccountsListViewController.h; sourceTree = "<group>"; };
+ 6865AA9E14ECC2CF00240660 /* AccountsListViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AccountsListViewController.m; sourceTree = "<group>"; };
+ 6865AAA114ECC2CF00240660 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/AccountsListViewController.xib; sourceTree = "<group>"; };
+ 6865AAA814ECC34F00240660 /* Accounts.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Accounts.framework; path = System/Library/Frameworks/Accounts.framework; sourceTree = SDKROOT; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
6865AA8414ECC2CF00240660 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
+ 6865AAA914ECC34F00240660 /* Accounts.framework in Frameworks */,
6865AA8C14ECC2CF00240660 /* UIKit.framework in Frameworks */,
6865AA8E14ECC2CF00240660 /* Foundation.framework in Frameworks */,
6865AA9014ECC2CF00240660 /* CoreGraphics.framework in Frameworks */,
@@ -67,6 +70,7 @@
6865AA8A14ECC2CF00240660 /* Frameworks */ = {
isa = PBXGroup;
children = (
+ 6865AAA814ECC34F00240660 /* Accounts.framework */,
6865AA8B14ECC2CF00240660 /* UIKit.framework */,
6865AA8D14ECC2CF00240660 /* Foundation.framework */,
6865AA8F14ECC2CF00240660 /* CoreGraphics.framework */,
@@ -79,9 +83,9 @@
children = (
6865AA9A14ECC2CF00240660 /* AppDelegate.h */,
6865AA9B14ECC2CF00240660 /* AppDelegate.m */,
- 6865AA9D14ECC2CF00240660 /* ViewController.h */,
- 6865AA9E14ECC2CF00240660 /* ViewController.m */,
- 6865AAA014ECC2CF00240660 /* ViewController.xib */,
+ 6865AA9D14ECC2CF00240660 /* AccountsListViewController.h */,
+ 6865AA9E14ECC2CF00240660 /* AccountsListViewController.m */,
+ 6865AAA014ECC2CF00240660 /* AccountsListViewController.xib */,
6865AA9214ECC2CF00240660 /* Supporting Files */,
);
path = TWAccountList;
@@ -150,7 +154,7 @@
buildActionMask = 2147483647;
files = (
6865AA9614ECC2CF00240660 /* InfoPlist.strings in Resources */,
- 6865AAA214ECC2CF00240660 /* ViewController.xib in Resources */,
+ 6865AAA214ECC2CF00240660 /* AccountsListViewController.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -163,7 +167,7 @@
files = (
6865AA9814ECC2CF00240660 /* main.m in Sources */,
6865AA9C14ECC2CF00240660 /* AppDelegate.m in Sources */,
- 6865AA9F14ECC2CF00240660 /* ViewController.m in Sources */,
+ 6865AA9F14ECC2CF00240660 /* AccountsListViewController.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -178,12 +182,12 @@
name = InfoPlist.strings;
sourceTree = "<group>";
};
- 6865AAA014ECC2CF00240660 /* ViewController.xib */ = {
+ 6865AAA014ECC2CF00240660 /* AccountsListViewController.xib */ = {
isa = PBXVariantGroup;
children = (
6865AAA114ECC2CF00240660 /* en */,
);
- name = ViewController.xib;
+ name = AccountsListViewController.xib;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
@@ -0,0 +1,21 @@
+//
+// ViewController.h
+// TWAccountList
+//
+// Created by Tatsuya Arai on 12/02/16.
+// Copyright (c) 2012 genesix, Inc. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import <Accounts/Accounts.h>
+
+@interface AccountsListViewController : UITableViewController
+{
+ ACAccountStore *_accountStore;
+ NSArray *_accounts;
+}
+
+@property (nonatomic, retain) ACAccountStore *accountStore;
+@property (nonatomic, retain) NSArray *accounts;
+
+@end
@@ -0,0 +1,109 @@
+//
+// ViewController.m
+// TWAccountList
+//
+// Created by Tatsuya Arai on 12/02/16.
+// Copyright (c) 2012 genesix, Inc. All rights reserved.
+//
+
+#import "AccountsListViewController.h"
+
+@implementation AccountsListViewController
+
+@synthesize accounts = _accounts;
+@synthesize accountStore = _accountStore;
+
+- (void)didReceiveMemoryWarning
+{
+ [super didReceiveMemoryWarning];
+ // Release any cached data, images, etc that aren't in use.
+}
+
+#pragma mark - Data handling
+
+- (void)fetchAccountData
+{
+ if (self.accountStore == nil) {
+ self.accountStore = [[ACAccountStore alloc] init];
+ if (self.accounts == nil) {
+ ACAccountType *accountTypeTwitter = [self.accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
+ [self.accountStore requestAccessToAccountsWithType:accountTypeTwitter withCompletionHandler:^(BOOL granted, NSError *error) {
+ if (granted) {
+ self.accounts = [self.accountStore accountsWithAccountType:accountTypeTwitter];
+ dispatch_sync(dispatch_get_main_queue(), ^{
+ [self.tableView reloadData];
+ });
+ }
+ }];
+ }
+ }
+}
+
+#pragma mark - View lifecycle
+
+- (void)viewDidLoad
+{
+ [super viewDidLoad];
+ // Do any additional setup after loading the view, typically from a nib.
+ [self fetchAccountData];
+}
+
+- (void)viewDidUnload
+{
+ [super viewDidUnload];
+ // Release any retained subviews of the main view.
+ // e.g. self.myOutlet = nil;
+}
+
+- (void)viewWillAppear:(BOOL)animated
+{
+ [super viewWillAppear:animated];
+}
+
+- (void)viewDidAppear:(BOOL)animated
+{
+ [super viewDidAppear:animated];
+}
+
+- (void)viewWillDisappear:(BOOL)animated
+{
+ [super viewWillDisappear:animated];
+}
+
+- (void)viewDidDisappear:(BOOL)animated
+{
+ [super viewDidDisappear:animated];
+}
+
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
+{
+ // Return YES for supported orientations
+ return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
+}
+
+#pragma mark - Table view data source
+
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
+{
+ return [self.accounts count];
+}
+
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
+{
+ static NSString *CellIdentifier = @"Cell";
+
+ UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
+ if (cell == nil) {
+ cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
+ }
+
+ ACAccount *account = [self.accounts objectAtIndex:[indexPath row]];
+ cell.textLabel.text = account.username;
+ cell.detailTextLabel.text = account.accountDescription;
+
+ cell.selectionStyle = UITableViewCellSelectionStyleNone;
+
+ return cell;
+}
+
+@end
@@ -2,18 +2,18 @@
// AppDelegate.h
// TWAccountList
//
-// Created by 荒井 達哉 on 12/02/16.
-// Copyright (c) 2012年 genesix, Inc. All rights reserved.
+// Created by Tatsuya Arai on 12/02/16.
+// Copyright (c) 2012 genesix, Inc. All rights reserved.
//
#import <UIKit/UIKit.h>
-@class ViewController;
+@class AccountsListViewController;
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
-@property (strong, nonatomic) ViewController *viewController;
+@property (strong, nonatomic) AccountsListViewController *viewController;
@end
@@ -2,13 +2,13 @@
// AppDelegate.m
// TWAccountList
//
-// Created by 荒井 達哉 on 12/02/16.
-// Copyright (c) 2012年 genesix, Inc. All rights reserved.
+// Created by Tatsuya Arai on 12/02/16.
+// Copyright (c) 2012 genesix, Inc. All rights reserved.
//
#import "AppDelegate.h"
-#import "ViewController.h"
+#import "AccountsListViewController.h"
@implementation AppDelegate
@@ -26,7 +26,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
- self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
+ self.viewController = [[[AccountsListViewController alloc] init] autorelease];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
@@ -1,13 +0,0 @@
-//
-// ViewController.h
-// TWAccountList
-//
-// Created by 荒井 達哉 on 12/02/16.
-// Copyright (c) 2012年 genesix, Inc. All rights reserved.
-//
-
-#import <UIKit/UIKit.h>
-
-@interface ViewController : UIViewController
-
-@end
@@ -1,60 +0,0 @@
-//
-// ViewController.m
-// TWAccountList
-//
-// Created by 荒井 達哉 on 12/02/16.
-// Copyright (c) 2012年 genesix, Inc. All rights reserved.
-//
-
-#import "ViewController.h"
-
-@implementation ViewController
-
-- (void)didReceiveMemoryWarning
-{
- [super didReceiveMemoryWarning];
- // Release any cached data, images, etc that aren't in use.
-}
-
-#pragma mark - View lifecycle
-
-- (void)viewDidLoad
-{
- [super viewDidLoad];
- // Do any additional setup after loading the view, typically from a nib.
-}
-
-- (void)viewDidUnload
-{
- [super viewDidUnload];
- // Release any retained subviews of the main view.
- // e.g. self.myOutlet = nil;
-}
-
-- (void)viewWillAppear:(BOOL)animated
-{
- [super viewWillAppear:animated];
-}
-
-- (void)viewDidAppear:(BOOL)animated
-{
- [super viewDidAppear:animated];
-}
-
-- (void)viewWillDisappear:(BOOL)animated
-{
- [super viewWillDisappear:animated];
-}
-
-- (void)viewDidDisappear:(BOOL)animated
-{
- [super viewDidDisappear:animated];
-}
-
-- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
-{
- // Return YES for supported orientations
- return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
-}
-
-@end
Oops, something went wrong. Retry.

0 comments on commit 3f0b7bf

Please sign in to comment.