Popular Posts

There was an error in this gadget

Mar 29, 2011

First Program for iPhone

 Hello world ..... THis is the first application i made for iPhone.Take a lebel,text box, and a button...
Then type the code....



//
//  ShitShipAppDelegate.h
//  ShitShip
//
//  Created by JUBAYER Ahmed on 3/27/11.
//  Copyright CODEMAGNETS 2011. All rights reserved.
//

#import <UIKit/UIKit.h>

@class ShipController;


@interface ShitShipAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
ShipController *shipController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) ShipController *shipController;
@end


//
//  ShitShipAppDelegate.m
//  ShitShip
//
//  Created by JUBAYER Ahmed on 3/27/11.
//  Copyright CODEMAGNETS 2011. All rights reserved.
//

#import "ShitShipAppDelegate.h"
#import "ShipController.h"

@implementation ShitShipAppDelegate

@synthesize window;
@synthesize shipController;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    ShipController *viewShipController = [[ShipController alloc]initWithNibName:@"ShipView" bundle:[NSBundle mainBundle]];
self.shipController = viewShipController;
[viewShipController release];
UIView *controllerView = [viewShipController view];
[window addSubview:controllerView];
//[window addSubview:[viewShipController view]];
[window makeKeyAndVisible];
}


- (void)dealloc {
[shipController release];
    [window release];
    [super dealloc];
}


@end


//
//  ShipController.h
//  ShitShip
//
//  Created by JUBAYER Ahmed on 3/27/11.
//  Copyright 2011 CODEMAGNETS. All rights reserved.
//

#import <UIKit/UIKit.h>


@interface ShipController : UIViewController {
UITextField *textField;
UILabel *label;
NSString *string;
}

@property(nonatomic,retain)IBOutlet UITextField *textField;
@property(nonatomic,retain)IBOutlet UILabel *label;
@property(nonatomic,copy) NSString *string;

-(IBAction)changeGreeting:(id)sender;
@end



//
//  ShipController.m
//  ShitShip
//
//  Created by JUBAYER Ahmed on 3/27/11.
//  Copyright 2011 CODEMAGNETS. All rights reserved.
//

#import "ShipController.h"


@implementation ShipController
@synthesize textField;
@synthesize label;
@synthesize string;

-(IBAction)changeGreeting:(id)sender{
self.string = textField.text;
NSString *nameString = string;
if([nameString length] == 0){
nameString = @"world";
}
NSString *greeting = [[NSString alloc] initWithFormat:@"Hello. %@!",nameString];
label.text = greeting;
[greeting release];
}

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
[textField release];
[label release];
[string release];
    [super dealloc];
}


@end


















No comments:

Post a Comment