出于某种原因,我的自定义委托为零。这是代码:
。H
@protocol AssignmentDelgate <NSObject>
-(void)newAssignment:(AssignmentInfo *)assignment;
@end
@property (nonatomic,weak)id<AssignmentDelgate> otherdelegate;
.m
- (IBAction)addTheInfo:(id)sender {
[self.otherdelegate newAssignment:self.assignmentInfo];
NSLog(@"%@",self.otherdelegate); //Returning nil!
}
另一个VC.h:
@interface AssignmentListViewController : UITableViewController<AssignmentDelgate,UITextFieldDelegate>
@property(strong,nonatomic) AddEditViewController *vc;
@property (strong, nonatomic) NSMutableArray *alist;
另一个VC.m
-(void)newAssignment:(AssignmentInfo *)assignment
{
[self.alist addObject:assignment];
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.vc.otherdelegate = self;
// 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;
}
为什么代表为零?我重写了应用程序,但没有任何区别。项目链接: http ://steveedwin.com/AssignmentAppTwo.zip