Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can either add an NSString * property to the ViewControllerClass and set it after you init it (this would be the easiest), or you can create your own init method that takes a string and sets it there.</p> <p><strong>Option 1:</strong></p> <p>(place this in your .h file)</p> <pre><code>@interface ViewControllerClass : UIViewController { NSString *someString; } @property (nonatomic, copy) NSString *someString; @end </code></pre> <p>(Then in your .m file)</p> <pre><code>@implementation ViewControllerClass @synthesize someString; @end </code></pre> <p>Alter your code from above to this:</p> <pre><code>-(IBAction) viewPictures{ ViewControllerClass *sView = [[ViewControllerClass alloc] initWithNibName:@"ViewController2XIB" bundle:nil]; sView.someString = @"Whatever String you want"; [self.navigationController pushViewController:sView animated:YES]; } </code></pre> <p><strong>Option 2:</strong></p> <p>(place this in your .h file)</p> <pre><code>@interface ViewControllerClass : UIViewController { NSString *someString; } - (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle someString:(NSString *)SomeString; @end </code></pre> <p>(Then in your .m file)</p> <pre><code>@implementation ViewControllerClass - (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle someString:(NSString *)SomeString { if(self = [super initWithNibName:nibName bundle:nibBundle]) { someString = [SomeString copy]; } return self; } @end </code></pre> <p>Alter your code from above to this:</p> <pre><code>-(IBAction) viewPictures{ ViewControllerClass *sView = [[ViewControllerClass alloc] initWithNibName:@"ViewController2XIB" bundle:nil someString:@"Whatever String you want"]; [self.navigationController pushViewController:sView animated:YES]; } </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.
    3. 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