何らかの理由で、私のカスタム デリゲートは nil です。コードは次のとおりです。
.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;
}
デリゲートが nil なのはなぜですか? アプリを書き直しましたが、違いはありませんでした。プロジェクトへのリンク: http://steveedwin.com/AssignmentAppTwo.zip