-1

MasterViewController.h

NSString *quality;

MasterViewController.m

#import DetailViewController.h

-(void)viewDidLoad {
    quality = [NSString stringWithFormat:@"string to pass"];

    ...

}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([[segue identifier] isEqualToString:@"showDetail"]) {
        DetailViewController *detailView = [segue destinationViewController];

        NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];

        theList = [app.listArray objectAtIndex:indexPath.row];

        detailView.theList = theList;

        detailView.streamQuality = quality;

    }
}

DetailViewController.h

@property (nonatomic ,retain) NSString *streamQuality;

DetailViewController.m

@synthesize streamQuality;

NSLog(@"Final: %@", streamQuality);

Output: Most I get "Thread 1: EXC_BAD_ACCESS(code=2, address=0x10)"
or something random like "Final: Copy Audio Address"



However this works fine:

detailView.streamQuality = @"hello";
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Lorenz
  • 11
  • 4
  • what is quality ? have you checked its value before passing it ot detailViewController ? – Prashant Nikam Sep 17 '13 at 10:48
  • Are you using ARC? If not then stringWithFormat returns autoreleased string, so you need to retain it. Try using: quality = [[NSString stringWithFormat:@"string to pass"] retain];. – Nuzhat Zari Sep 17 '13 at 11:17

1 Answers1

1

You should create a property to retain NSString Object quality. For Eg :

@property (nonatomic ,copy) NSString *quality;

and of course you have to synthesize it :

@synthesize quality;

and then you should use this property to set the string. Like this :

self.quality = @"string to pass";
Bhavin
  • 27,155
  • 11
  • 55
  • 94