Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 委托错误,我没有';我不知道为什么_Ios_Objective C_Delegates - Fatal编程技术网

Ios 委托错误,我没有';我不知道为什么

Ios 委托错误,我没有';我不知道为什么,ios,objective-c,delegates,Ios,Objective C,Delegates,我有一个1错误,我不明白为什么? 我将张贴所有的代码,因为我已经在过去的3个小时看这个,并已放弃 // //AssignmentListViewController.h // AssignmentAppTwo // // Created by Abdel Elrafa on 10/11/13. // Copyright (c) 2013 Abdel Elrafa. All rights reserved. // #import <UIKit/UIKit.h> #import

我有一个1错误,我不明白为什么? 我将张贴所有的代码,因为我已经在过去的3个小时看这个,并已放弃

// //AssignmentListViewController.h

//  AssignmentAppTwo
//
//  Created by Abdel Elrafa on 10/11/13.
//  Copyright (c) 2013 Abdel Elrafa. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "AddEditViewController.h"

@interface AssignmentListViewController : UITableViewController

@property(strong,nonatomic) AddEditViewController *vc;



@end
//  AssignmentAppTwo
//
//  Created by Abdel Elrafa on 10/11/13.
//  Copyright (c) 2013 Abdel Elrafa. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "AssignmentInfo.h"

@protocol AddAssignmentDelegate;


@interface AddEditViewController : UITableViewController

<

UITextFieldDelegate

>
{
    IBOutlet UIDatePicker *dateTimePicker;
}

@property (nonatomic, strong) IBOutlet UITextField *className;
@property (nonatomic, strong) IBOutlet UITextField *assignmentTitle;
@property (nonatomic, strong) IBOutlet UITextField *assignmentDescription;
@property (nonatomic, strong) IBOutlet UISwitch *procrastinationNotificationSwitch;
@property (nonatomic,strong)AssignmentInfo *assignmentInfo;
@property (nonatomic, weak)  id <AddAssignmentDelegate> delegate;


@end

@protocol ViewControllerDelegate <NSObject>

-(void)assignmentSaved:(AssignmentInfo *)classObj;


@end
\\我的错误在这里

    [self.delegate assignmentSaved:self.assignmentInfo];
    NSLog(@"%@",self.delegate);
//错误^^^^^^
}

我在上面概述了我的错误。我放弃了,因为我看不出哪里出了问题。

@interface AssignmentListViewController : UITableViewController
应该成为

@interface AssignmentListViewController : UITableViewController <AddAssignmentDelegate>
@接口分配ListViewController:UITableViewController

这是我能看到的唯一问题,但您只需要发布相关代码,并发出错误消息就好了

您使用的是AddAssignmentDelegate,但从我看到的情况来看,您将委托定义为ViewControllerDelegate


因此,AddAssignmentDelegate基本上没有定义,没有委托函数

您能告诉我发生了什么错误消息吗?@KyokookHwang error for:[self.delegate assignmentSaved:self.assignmentInfo];选择器“assignmentSaved:”没有已知的实例方法,感谢您捕捉到它,但在我添加它之后,它说找不到“AddAssignmentDelegate”的协议定义,并且另一个错误仍然存在:[self.delegate assignmentSaved:self.assignmentInfo];选择器“assignmentSaved:”没有已知的实例方法。谢谢!
-(AssignmentInfo *)assignmentInfo
{
    if (!_assignmentInfo) {
        _assignmentInfo = [[AssignmentInfo alloc]init];
    }
    return _assignmentInfo;


}

- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];


    [_procrastinationNotificationSwitch addTarget:self action:@selector(procrastinationNotificationSwitchOnOrOff) forControlEvents:UIControlEventValueChanged];
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissKeyboard)];

    [self.view addGestureRecognizer:tap];   // Do any additional setup after loading the view, typically from a nib.

    self.assignmentInfo.notifcationStatus = YES;


    self.className.tag = 0;
    self.className.delegate = self;

    self.assignmentTitle.tag = 1;
    self.assignmentTitle.delegate = self;

    self.assignmentDescription.tag = 2;
    self.assignmentDescription.delegate = self;


    AssignmentInfo *classUnarchived = [NSKeyedUnarchiver unarchiveObjectWithFile:[self dataFilePath]];

    NSLog(@"%@" @"log of archive",classUnarchived.description);




    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;

    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



#pragma mark - Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Navigation logic may go here. Create and push another view controller.
    /*
     <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
     // ...
     // Pass the selected object to the new view controller.
     [self.navigationController pushViewController:detailViewController animated:YES];
     */
}

@end
//  AssignmentAppTwo
//
//  Created by Abdel Elrafa on 10/11/13.
//  Copyright (c) 2013 Abdel Elrafa. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface AssignmentInfo : NSObject

@property (nonatomic,strong)NSString *className;
@property (nonatomic,strong)NSString *assignmentDescription;
@property (nonatomic,strong)NSString *assignmentTitle;
@property (nonatomic,strong)NSString *dateTimeString;

@property (nonatomic)bool notifcationStatus;
-(id)initWithCoder:(NSCoder *)aDecoder;
-(void)encodeWithCoder:(NSCoder *)aCoder;

@end
//  AssignmentAppTwo
//
//  Created by Abdel Elrafa on 10/11/13.
//  Copyright (c) 2013 Abdel Elrafa. All rights reserved.
//

#import "AssignmentInfo.h"

@implementation AssignmentInfo


-(NSString *)description
{

    return [NSString stringWithFormat:@"Class: %@\r Assignment Title: %@ \rAssignment Description: %@ \rDue: %@ \r%s", self.className, self.assignmentTitle, self.assignmentDescription, self.dateTimeString,self.notifcationStatus ? "Notification On" : "Notification Off"];
}


-(id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super init];

    self.className = [aDecoder decodeObjectForKey:@"className"];
    self.assignmentTitle = [aDecoder decodeObjectForKey:@"assignmentTitle"];
    self.assignmentDescription = [aDecoder decodeObjectForKey:@"assignmentDescription"];
    self.dateTimeString = [aDecoder decodeObjectForKey:@"dateTimeString"];
    self.notifcationStatus = [aDecoder decodeObjectForKey:@"notifcationStatus"];

    return self;
}

-(void)encodeWithCoder:(NSCoder *)aCoder
{
    [aCoder encodeObject:self.className forKey:@"className"];
    [aCoder encodeObject:self.assignmentTitle forKey:@"assignmentTitle"];
    [aCoder encodeObject:self.assignmentDescription forKey:@"assignmentDescription"];
    [aCoder encodeObject:self.dateTimeString forKey:@"dateTimeString"];
    [aCoder encodeBool:self.notifcationStatus forKey:@"notificationStatus"];
}



@end
@interface AssignmentListViewController : UITableViewController
@interface AssignmentListViewController : UITableViewController <AddAssignmentDelegate>