Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // ViewController.m
- // Labb3TodoList
- //
- // Created by Henrik Doré on 2020-01-20.
- // Copyright © 2020 Henrik Doré. All rights reserved.
- //
- #import "ViewController.h"
- #import "addNewTodoViewController.h"
- @interface ViewController ()
- @synthesize todoListArray;
- @synthesize todolistArrayNewFromUser;
- @end
- @implementation ViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- }
- -(void)viewDidAppear:(BOOL)animated{
- [self getUserDefaults];
- [_tableView reloadData];
- }
- - (void) getUserDefaults{
- NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
- _todolistArrayNewFromUser = [[defaults objectForKey:@"todoarrayKey"] mutableCopy];
- if(_todolistArrayNewFromUser == nil){
- _todolistArrayNewFromUser = [[NSMutableArray alloc] init];
- }
- }
- //Denna måste finnas med tror jag. Så att den vet antal sektioner. I detta fallet 1 sektion.
- -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- return [todolistArrayNewFromUser count];
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"cell"];
- if (cell == nil){
- cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
- }
- cell.textLabel.text = [todolistArrayNewFromUser objectAtIndex:indexPath.row];
- return cell;
- }
- - (IBAction)newtodoBtn:(id)sender {
- }
- - (IBAction)updateBtn:(id)sender {
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement