How do I set the value of recipientItems in the following code snippet?
#import <UIKit/UIKit.h>
@interface开发者_StackOverflow社区 AddRecipientsTableViewController : UITableViewController {
NSMutableArray *recipientItems;
}
-(IBAction) btnLocalRecipients;
-(IBAction) btnRemoteRecipients;
-(IBAction) btnNext;
@end
In my implementation I have:
#import "AddRecipientsTableViewController.h"
#import "AddLocalRecipientsTableViewController.h"
#import "AddRemoteRecipientsTableViewController.h"
@implementation AddRecipientsTableViewController
-(IBAction) btnLocalRecipients{
AddLocalRecipientsTableViewController *addLocalRecipientsTableViewController = [[AddLocalRecipientsTableViewController alloc]init];
addLocalRecipientsTableViewController.navigationItem.title=@"Local Recipients";
[self.navigationController pushViewController:addLocalRecipientsTableViewController animated:YES];
[addLocalRecipientsTableViewController release];
}
How do I set the value for recipientItems from within addLocalRecipientsTableViewController?
You have two options.
Option A Create an init method in your AddLocalRecipientsTableViewController that accepts a pointer to recipentItems.
I would choose option A if I would want to manage adding inside the viewController.
Option B Use NSNotifications to send a new recipient when it is created.
I would choose option B if I would want to manage all tasks related to recipientItems in one class AddRecipientsTableViewController.
精彩评论