Advertisement
Guest User

main.m

a guest
Apr 24th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #import <Foundation/Foundation.h>
  2. #import <Foundation/NSArray.h>
  3. #import "Task.h"
  4. #import "TodoList.h"
  5.  
  6. void showTasks(NSMutableArray* tasks);
  7.  
  8. int main (int argc, const char * argv[])
  9. {
  10.    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
  11.  
  12.     TodoList* todoList = [[ TodoList alloc ] init];
  13.      [ todoList addTask: @"task 1"  iscompleted: false priority : 3];
  14.          [ todoList addTask];
  15.       [ todoList addTask: @"task 2"  iscompleted: true priority : 2];
  16.        [ todoList addTask: @"task 3"  iscompleted: false priority : 5];
  17.      [ todoList addTask: @"task 4"  iscompleted: true priority : 1];
  18.      [ todoList showTasks ];
  19.  
  20.     NSMutableArray *mListTasks;
  21.  
  22.     NSLog(@"Completed tasks: ");
  23.     mListTasks = [todoList getCompletedTasks];
  24.     showTasks(mListTasks);
  25.      
  26.     NSLog(@"Not Completed tasks: ");
  27.     mListTasks = [todoList getNotCompletedTasks];
  28.     showTasks(mListTasks);
  29.    
  30.    [pool drain];
  31.    return 0;
  32. }
  33. void showTasks(NSMutableArray* tasks) {
  34.     int i;
  35.      for(i = 0; i < tasks.count; ++i) {
  36.         Task *t = [tasks objectAtIndex: i];
  37.         NSLog(t.task);
  38.         NSLog(t.iscompleted ? @"Completed" : @"Not completed");
  39.         NSLog(@"%d",t.priority);
  40.         NSLog(@"---------------------------------*****-");
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement