0

I am trying to pass data from a UITextView in one view controller to UITextView in another view controller. My application is using Storyboards.

in the first view controller I say:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
LyricKaraokeViewController *karaokeController = segue.destinationViewController;
karaokeController.hidesBottomBarWhenPushed = YES;
SongDoc *song = [[SongDoc alloc] initWithTitle:@"Title" lyrics:@"Test" thumbImage:nil];
karaokeController.detailItem = song;
NSLog(@"%@", karaokeController.detailItem.data.lyrics); 
}

The NSLog outputs the appropriate text

In my second view controller I declare this interface:

@class SongDoc;

@interface LyricKaraokeViewController : UIViewController

@property (nonatomic, retain) SongDoc * detailItem;

@end

and this implementation ( just showing viewDidLoad for simplicity ):

 - (void)viewDidLoad
 {

NSLog(@"%@", self.detailItem.data.lyrics);

    [super viewDidLoad];
 } 

and I confirm that there is the properties data.lyrics in the detailItem because we are passing in a SongDoc object and I output the SongDocs contents in prepareForSegue just prior....

My problem is in the second view controller I am receiving an error saying the detail item doesn't declare the property lyrics

But I know this is untrue so why is this happening?

any help would be great thanks :)

Mundi
  • 79,884
  • 17
  • 117
  • 140
  • you should post the exact error message and the line flagged with it. one more question: if you get the error, how can you run the app and confirm that all is ok through the NSLogs? – sergio Nov 11 '12 at 11:04

1 Answers1

1
@class SongDoc;

only tells the compiler that SongDoc is a class, but does not read the implementation file. You have to

#import "SongDoc.h"

instead, so that the compiler knows which properties are declared by the class.

Martin R
  • 529,903
  • 94
  • 1,240
  • 1,382
  • 1
    @AdamDahan: You are welcome. - I have noticed that you have not accepted any answer yet. You should accept answers that helped by clicking on the check mark outline to the left of the answer. – Martin R Nov 11 '12 at 11:08
  • Thanks alot I didn't even realize there was a checkmark button.. New to stack :) –  Nov 17 '12 at 20:27