ViewController gets deallocated which leads to crash

Best way to deal with this is using a property. Here's how:

In your .h file:

#import "MainViewController.h"

@interface MyClass : UIViewController

@property (strong, nonatomic) MainViewController *mvc;


In your .m file:

#import "MyClass.h"

@implementation MyClass

@synthesize mvc;

// Your code here
- (void)yourMethodHere {
self.mvc = [self.storyboard instantiateViewControllerWithIdentifier:@"MainView"];
[self.view addSubview:mvc.view];

New hot tips

UIAlertView in one line

Three useful UIWebView tweaks

iOS QR encoder for iOS

Load a PDF File in the iPhone App Smoothly

Excellent Easy To Use Flip (Flipboard Style) Transition Component


How to change/customize mail signature in Mountain Lion?

• open Mail
• create a new signature
• open this folder /Users/you/Library/Mail/V2/MailData/Signatures/
• open the latest *.mailsignature file with a text editor
• replace everything under this code with your custom html (replace iso-8859-1 with uft-8for umlaut support)

Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
Message-Id: <[email protected]_W_722V_Typ_B>
Mime-Version: 1.0 (Mac OS X Mail 6.0 \(1486\))

• save the file and open the Get Info Dialogue and check Locked, so that it doesn't get overwritten by Mail