Note that there are some explanatory texts on larger screens.

plurals
  1. POiPhone memory management, EXC_BAD_ACCESS NSString between views
    primarykey
    data
    text
    <p>I have some problems with memory management, I think my problem is the assignment, and object releases. I want to assign a NSString (userID) value to another NSString in other view (user_id).</p> <p><strong>MainViewController.h</strong></p> <pre><code>#import "OnlineCheckViewController.h" @interface MainViewController : UIViewController { NSString *userID; } @end </code></pre> <p><strong>MainViewController.m</strong></p> <pre><code>#import "MainViewController.h" - (IBAction)OnlineCheck:(id)sender { OnlineCheckViewController *controller = [[OnlineCheckViewController alloc] initWithNibName:@"OnlineCheckViewController" bundle:nil]; controller.delegate = self; controller.user_id = userID; controller.modalTransitionStyle = UIModalTransitionStyleCoverVertical; [self presentModalViewController:controller animated:YES]; [controller release]; } - (void)viewDidUnload { userID = nil; [super viewDidUnload]; } - (void)dealloc { [userID release]; [super dealloc]; } </code></pre> <p><strong>OnlineCheckViewController.h</strong></p> <pre><code>#import &lt;UIKit/UIKit.h&gt; #import "OnlineCheckResultsViewController.h" @protocol OnlineCheckViewControllerDelegate; @interface OnlineCheckViewController : UIViewController &lt;OnlineCheckResultsViewControllerDelegate&gt; { NSString *user_id; } @property (nonatomic, assign) id &lt;OnlineCheckViewControllerDelegate&gt; delegate; @property (nonatomic, retain) NSString *user_id; @end </code></pre> <p><strong>OnlineCheckViewController.m</strong></p> <pre><code>#import "OnlineCheckViewController.h" @synthesize user_id; @synthesize delegate=_delegate; - (void)dealloc { [user_id release]; [super dealloc]; } - (void)viewDidUnload { [self setUser_id:nil]; [super viewDidUnload]; } </code></pre> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    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. 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