Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You don't need to use NSUserDefaults to pass data between view controllers. You can set the string in BBBViewController in the prepareForSegue method of AAAViewController</p> <p>AAAViewController.m:</p> <pre><code>@implementation AAAViewController { NSString *libraryFile; } -(IBAction)pressedAAA { libraryFile = [[NSBundle mainBundle] pathForResource:@"AAA" ofType:@"plist"]; } -(IBAction)pressedBBB { libraryFile = [[NSBundle mainBundle] pathForResource:@"BBB" ofType:@"plist"]; } -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { BBBViewController* vc = (BBBViewController *)segue.destinationViewController; vc.libraryFile = libraryFile; } </code></pre> <p>BBBViewController.h:</p> <pre><code>@property (strong, nonatomic) NSString *libraryFile; </code></pre> <p><strong>EDIT:</strong> prepareForSegue will be called before your IBAction methods. To fix this, give each button a unique tag in interface builder and determine which button was pressed inside of the prepareForSegue method: </p> <pre><code>-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { UIButton *tappedButton = (UIButton *)sender; NSString *libraryFile; switch (tappedButton.tag) { case 0: libraryFile = [[NSBundle mainBundle] pathForResource:@"AAA" ofType:@"plist"]; break; case 1: libraryFile = [[NSBundle mainBundle] pathForResource:@"BBB" ofType:@"plist"]; break; case 2: libraryFile = [[NSBundle mainBundle] pathForResource:@"CCC" ofType:@"plist"]; break; default: break; } BBBViewController* vc = (BBBViewController *)segue.destinationViewController; vc.libraryFile = libraryFile; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload