Reputation: 14317
I have a ViewController
:
@interface SubmitCampaignViewController:UIViewController<SocialPagesViewControllerDelegate>
And a SocialPagesViewController
with UITableView
like this:
@protocol SocialPagesViewControllerDelegate;
@interface SocialPagesViewController : BaseViewController<UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, weak) id<SocialPagesViewControllerDelegate> delegate;
@property (nonatomic, weak) NSArray *pages;
@end
I would like to to pass data from SubmitCampaignViewController
to SocialPagesViewController
.
So I wrote like this:
SocialPagesViewController *socialViewController = [storyboard instantiateViewControllerWithIdentifier:@"socialPages"];
socialViewController.delegate = self;
socialViewController.pages = objects;
[self presentViewController:socialViewController animated:NO completion:NULL];
However, although objects is not 0, self.pages.count is 0.
SocialPagesViewController.m
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
DLog(@"%d",self.pages.count);
return self.pages.count;
}
How can I pass objects NSArray
from SubmitCampaignViewController
to SocialPagesViewController
?
Upvotes: 4
Views: 108
Reputation: 4249
I would recommend the setter of pages
to @property (nonatomic, copy) NSArray *pages;
since you require the same array object
into pages
.
At the point of presenting socialViewController..
socialViewController.pages = [objects copy];
Upvotes: 1
Reputation: 1807
Try setting the referrence of array as strong.
@property (nonatomic, strong) NSArray *pages;
Upvotes: 4