Getting error and dont get it


My error in xcode 5 is “Method definition for ‘addTask:’ not found”

My error in xcode 4 is “Incomplete implementation”

My .h file is

[code]#import <UIKit/UIKit.h>

// Declare a helper function that we will use to get a path
// to the location on disk where we can save
NSString *docPath(void);

@interface AppDelegate : UIResponder
UITableView *taskTable;
UITextField *taskField;
UIButton *insertButton;

NSMutableArray *tasks;


  • (void)addTask:(id)sender;

@property (strong, nonatomic) UIWindow *window;


My .m file is

[code]#import “AppDelegate.h”

// Helper function to fetch the path to our ro-do data stored on disk
NSString *docPath()
NSArray *pathList = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
return [[pathList objectAtIndex:0] stringByAppendingPathComponent:@“”];

@implementation AppDelegate

#pragma mark - Application delegate callbacks

  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    //attempt to load an existing to-do dataset from an array stored to disk
    NSArray *plist = [NSArray arrayWithContentsOfFile:docPath()];
    if (plist) {
    //if there was a dataset available, copy it into our instance variable
    tasks = [plist mutableCopy];
    } else {
    //otherwise, just create an empty one to get us started.
    tasks = [[NSMutableArray alloc] init];


    //create and configure the uiwondow instance
    //a cgrect is a struct with an origin (x,y) and size (width,height)
    CGRect windowFrame = [[UIScreen mainScreen] bounds];
    UIWindow *theWindow = [[UIWindow alloc] initWithFrame:windowFrame];
    [self setWindow:theWindow];

    //define the frame rectangles of three UI elements
    //CGrectMake () creates a CGRect from (x,y, width, height)
    CGRect tableFrame = CGRectMake(0, 80, 320, 380);
    CGRect fieldFrame = CGRectMake(20, 40, 200, 31);
    CGRect buttonFrame = CGRectMake(228, 40, 72, 31);

    // create and configure the table view
    taskTable = [[UITableView alloc] initWithFrame:tableFrame
    [taskTable setSeparatorStyle:UITableViewCellSeparatorStyleNone];

    //create and configure the text field where new tasks will be typed
    taskField = [[UITextField alloc] initWithFrame:fieldFrame];
    [taskField setBorderStyle:UITextBorderStyleRoundedRect];
    [taskField setPlaceholder:@“Type a task, Tap Insert”];

    // create and configure a rounded rect insert button
    insertButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [insertButton setFrame:buttonFrame];

    //buttons behave using a target/action callback
    // configure the insert button’s action to call this object’s -addTask: method
    [insertButton addTarget:self

    //give the button a title
    [insertButton setTitle:@"Insert"

    // add our three ui elements to the window
    [[self window] addSubview:taskTable];
    [[self window] addSubview:taskField];
    [[self window] addSubview:insertButton];

    // finalize the window and put it on the screen
    [[self window] setBackgroundColor:[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:.



In the AppDelegate class, you have declared the method addTask: but have not provided a definition for it.

You must provide a definition:

@implementation AppDelegate
- (void)addTask:(id)sender 


Where do I put the code?