Skip to content

Instantly share code, notes, and snippets.

@luizperes
Last active February 23, 2016 21:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luizperes/2560a035e1cfeec7ed7e to your computer and use it in GitHub Desktop.
Save luizperes/2560a035e1cfeec7ed7e to your computer and use it in GitHub Desktop.
//
// AppDelegate.m
// UITests
//
// Created by Luiz Fernando Peres on 2016-02-23.
// Copyright © 2016 Ideia do Luiz. All rights reserved.
//
#import "AppDelegate.h"
#import "ViewController.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UINavigationController *n = [[UINavigationController alloc] initWithRootViewController:[[ViewController alloc] init]];
self.window.rootViewController = n;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
@end
//
// ViewController.m
// UITests
//
// Created by Luiz Fernando Peres on 2016-02-23.
// Copyright © 2016 Ideia do Luiz. All rights reserved.
//
#import "ViewController.h"
#import "Detail.h"
@interface ViewController () <UITableViewDelegate, UITableViewDataSource>
@property (nonatomic) NSArray *tableData;
@property (nonatomic) UITableView *table;
@end
@implementation ViewController
#define REUSE @"reusableCell"
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = @"Table";
self.tableData = [NSArray arrayWithObjects:@"Jao", @"Jaca", @"Jessica", @"Felipe", @"Joaquina", @"Marvel", @"Delicia", @"UI", @"auaua", @"Jao", @"Jaca", @"Jessica", @"Felipe", @"Joaquina", @"Marvel", @"Delicia", @"UI", @"auaua", nil];
self.table = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
self.table.delegate = self;
self.table.dataSource = self;
[self.view addSubview:self.table];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [self.tableData count];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [self.table dequeueReusableCellWithIdentifier:REUSE];
if (!cell)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:REUSE];
}
cell.textLabel.text = self.tableData[indexPath.row];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"%@", self.tableData[indexPath.row]);
Detail *detail = [[Detail alloc]init];
detail.name = self.tableData[indexPath.row];
[self.navigationController pushViewController:detail animated:YES];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment