this seems just bizarre as i am not able to resolve it and stuck over it. I am using storyboard to navigate between tableview and a detailview. It was working fine when i was passing a single (NewsRecord) object from my tableview class(TopStoriesViewController) to my detail class(DetailNewsViewController). But now i need to pass an array of (NewsRecord) objects when moving to the detail class instead of a single (NewsRecord) object. But when i create a NSArray * in my detail class and try to access it in my tableview class in prepareForSegue method using the object of detail class it gives the following error—property ‘items’ not found on object of type ‘DetailNewsViewController *’ at compile time. items is a NSArray object which get its contents from the ‘entries’ which is also an NSArray in TopStoriesViewController class.
My question is why am i able to access getNewsDetails of DetailNewsViewController in TopStoriesViewController and not items.
My classes are as follows –
TopStoriesViewController.m
#import "DetailNewsViewController.h"
some code here....
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"ShowDetailedNews"]) {
DetailNewsViewController *detailNewsVC = [segue destinationViewController];
[segue.destinationViewController setHidesBottomBarWhenPushed:YES];
NSInteger indexForNewsSelectedFromTBV = [[self.tableView indexPathForSelectedRow] row];
[detailNewsVC setGetNewsDetails:[entries objectAtIndex:indexForNewsSelectedFromTBV]]; //This is working fine...
detailNewsVC.items=entries; //Error is occurring here...
}
}
DetailNewsViewController.h
#import "NewsRecord.h"
@interface DetailNewsViewController : UIViewController {
NewsRecord *getNewsDetails;
some other declarations...
NSArray *items;
}
@property(nonatomic,retain) NewsRecord *getNewsDetails;
@property(nonatomic,retain) NSArray *items;
@end
DetailNewsViewController.m
#import "DetailNewsViewController.h"
@synthesize getNewsDetails,items;
NewsRecord.h
@interface NewsRecord : NSObject {
NSString *newsTitle;
NSString *newsDescription;
}
@property(nonatomic,retain) NSString *newsTitle;
@property(nonatomic,retain) NSString *newsDescription;
@end
You should try to explicitely use the setter for items: