当我收到错误时,我正在制作一个名为iTahDoodle的程序,我的错误是“addTask的方法定义:'找不到”
这是我的代码:
#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:@"data.td"];
}
@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
style:UITableViewStylePlain];
[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
action:@selector(addTask:)
forControlEvents:UIControlEventTouchUpInside];
//give the button a title
[insertButton setTitle:@"Insert"
forState:UIControlStateNormal];
// 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;
}
我相信这是您需要查看的所有代码,但如果不添加评论。
答案 0 :(得分:0)
您需要在.m文件中实现该方法。