0

I'm on my way learning ios programming through the book named "IOS PROGRAMMING" by BNR.

And I need to create a project without storyboard to follow the book.

I just check this answer below, but It doesn't work for me somehow. Xcode 5 without Storyboard and ARC

The compiler says "Replace the TestViewController with UIViewController" in AppDelegate.m.

#import "AppDelegate.h"


@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] ;

    // Override point for customization after application launch.

    TestViewController *test = [[TestViewController alloc]     initWithNibName:@"TestViewController" bundle:nil];
    UINavigationController *nav = [[UINavigationController alloc]  initWithRootViewController:test];
    self.window.rootViewController = nav;

    [self.window makeKeyAndVisible];

    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application
{
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application
{
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
Cœur
  • 37,241
  • 25
  • 195
  • 267
Toshi
  • 6,012
  • 8
  • 35
  • 58
  • I'm very new in this so it might be a very stupid question,but for those who answer this, Thanks in advance! – Toshi Nov 25 '13 at 03:34
  • It seems like you miss to import the header file TestViewController.h . Could you please add code which shows this warning – Anil Varghese Nov 25 '13 at 04:26
  • Thanks Anil! When I add the the header file TestViewController.h , everything looks fine!! – Toshi Nov 25 '13 at 04:49

3 Answers3

0

Create a Empty application from the template .And then Add a ViewController to Project by right-click and add new file then choose and choose cocoa touch in left pane .

Then select the First option Objective-C Class and then give name for the class .

enter image description here

Choose UIViewController from subclasss .

enter image description here

Make sure checkbox with option ' With XIB or user interface ' is checked and then click next .

project without a storyboard is created in XCode 5

If you would like to navigation controller it can be achieved like the below code

Appdelegate.h

#import <UIKit/UIKit.h>

@class InitialViewController;


@interface SampleAppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@property (strong, nonatomic) InitialViewController *viewController;

@end

Appdelegate.m

#import "SampleAppDelegate.h"
#import "InitialViewController.h"

@implementation SampleAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.viewController = [[InitialViewController alloc]initWithNibName:@"InitialViewController" bundle:nil];
    UINavigationController *navi = [[UINavigationController alloc]initWithRootViewController:self.viewController];
    self.window.rootViewController = navi;
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    return YES;
}
Vinodh
  • 5,262
  • 4
  • 38
  • 68
  • Thanks but what if I'd add not only a ViewController but a NavigationController? Should I put something in " - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:" in in AppDelegate.m file? – Toshi Nov 25 '13 at 04:36
0

project Creating time unchecked the storyboard option

new project -> single view -> unchecked storyboard like below image enter image description here

Muralikrishna
  • 1,044
  • 10
  • 17
0

Inside appdelegate

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
        self.TestViewController = [[TestViewController alloc] initWithNibName:@"TestViewController" bundle:nil];
        self.navigationController = [[UINavigationController alloc] initWithRootViewController:self.TestViewController];
        self.window.rootViewController = self.navigationController;
    }
Vinodh
  • 5,262
  • 4
  • 38
  • 68