4

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
southpark
  • 541
  • 2
  • 5
  • 19
  • Try, clean the project then build again – Krrish Feb 13 '12 at 10:11
  • clean your project if dat doesn't work restart you xcode.... – Inder Kumar Rathore Feb 13 '12 at 10:34
  • @Krrish,@Inder Kumar Rathore: tried cleaning and deleting the derived data... Still not getting resolved – southpark Feb 13 '12 at 10:38
  • Can you copy paste the exact error showing – Krrish Feb 13 '12 at 10:40
  • @Krrish: Property 'items' not found on object of type 'DetailNewsViewController *' – southpark Feb 13 '12 at 10:47
  • For anyone hitting this issue without resolve, "destinationViewController" is actually a reserved term for the pointer to the view you want to segue to...they should have named it a bit better as I was getting it confused in some tutorials as the first part of the declaration i.e., DetailViewController *detailViewController = segue.detailViewController / [segue detailViewController ] – Matt Rowles Jul 21 '14 at 05:07

1 Answers1

0

You should try to explicitely use the setter for items:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
     if ([[segue identifier] isEqualToString:@"ShowDetailedNews"]) 
     {

     DetailNewsViewController *detailNewsVC = [segue destinationViewController];
    ...
     [detailNewsVC setItems:entries];

     }
} 
  • Thanks for the answer. My items array does get populated with the objects array. It dint strike me this will work. But can u reason me why does xcode throw a warning "DetailNewsViewController may not respond to 'setItems'" whereas previously when i used "setGetNewsDetails" to set my object I was not given any warning. Any why detailNewsVC.items throws an error. – southpark Feb 14 '12 at 05:50