Hey guys,
I built part of my app and sometimes when I run it, it works fine other times when I push a button that retrieves a global NSString value makes the app crash. The only thing I can think is that this caused by a memory leak from the NSString. I believe I have it initialized correctly and I am releasing it in the dealloc method.
Any ideas?
RootViewController.h
RootViewController.m
It is also important to note that in the app delegate I am calling the dealloc method...
Any ideas where this leak may be coming from? Have I properly defined/declared a global NSString?
Thanks!
I built part of my app and sometimes when I run it, it works fine other times when I push a button that retrieves a global NSString value makes the app crash. The only thing I can think is that this caused by a memory leak from the NSString. I believe I have it initialized correctly and I am releasing it in the dealloc method.
Any ideas?
RootViewController.h
Code:
@interface RootViewController: UIViewController {
// Declare the text views for viewing the messages on the app
IBOutlet UILabel *latestTxtView;
IBOutlet UILabel *unreadTxtView;
// Declare buttons for retrieving the messages
IBOutlet UIButton *latestTxtButton;
IBOutlet UIButton *sendButton;
// Declare string to hold values to be sent out
NSString *latestTxt;
}
@property(nonatomic,retain)IBOutlet UITextView *latestTxtView;
@property(nonatomic,retain)IBOutlet UITextView *unreadTxtView;
@property(nonatomic,retain)IBOutlet UIButton *latestTxtButton;
@property(nonatomic,retain)IBOutlet UIButton *sendButton;
@property(nonatomic,retain)NSString *latestTxt;
// Action Items for the buttons
- (IBAction)getLatestTxt:(id)sender;
- (IBAction)pushSendButton:(id)sender;
@end
RootViewController.m
Code:
@implementation RootViewController
@synthesize latestTxtView, unreadTxtView, latestTxtButton, sendButton, latestTxt;
- (IBAction)getLatestTxt:(id)sender {
....
latestTxt = [NSString stringWithCString:contentTxt encoding:NSUTF8StringEncoding];
....
}
- (IBAction)pushSendButton:(id)sender {
....
unreadTxtView.text = latestTxt; // I believe this is the leak
}
@end
It is also important to note that in the app delegate I am calling the dealloc method...
Code:
- (void)dealloc {
[_latestTxt release];
[_latestTxtView release];
[_latestTxtButton release];
[_unreadTxtView release];
[_viewController release];
[_window release];
[super dealloc];
}
Any ideas where this leak may be coming from? Have I properly defined/declared a global NSString?
Thanks!