Welcome to Dream.In.Code
Click Here
Getting Help is Easy!

Join 117,608 Programmers for FREE! Ask your question and get quick answers from experts. There are 2,443 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Objective-C iphone ?help?

 
Reply to this topicStart new topic

Objective-C iphone ?help?

polymath
post 14 Jun, 2008 - 05:38 PM
Post #1


D.I.C Regular

Group Icon
Joined: 4 Apr, 2008
Posts: 390



Thanked 4 times

Dream Kudos: 500
My Contributions


just learning this one, looking for some support for my hello world program.

it has a few files:

1. TESTViewController.h

2. TESTViewController.m

3. TESTAppDelegate.h

4. TESTAppDelegate.m

5. main.m

TESTViewController.h
CODE

//
//  TESTViewController.h
//  TEST
//
//  Created by Aaron Sky on 6/14/08.
//  Copyright __MyCompanyName__ 2008. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface TESTViewController : UIViewController {

}

@end

TESTViewController.m
CODE
//
//  TESTAppDelegate.m
//  TEST
//
//  Created by Aaron Sky on 6/14/08.
//  Copyright __MyCompanyName__ 2008. All rights reserved.
//

#import "TESTViewController.h"

@implementation TESTViewController

/*
Implement loadView if you want to create a view hierarchy programmatically
- (void)loadView {
}
*/

/*
Implement viewDidLoad if you need to do additional setup after loading the view.
- (void)viewDidLoad {
    [super viewDidLoad];
}
*/

-(void)DispHelloWorld
{
    int  lmargin=0;
    int height=40;
    int width=320;
    int tmargin=40;
    CGRect frame = CGRectMake(lmargin, tmargin, width, height);
    UILabel *label = [[UILabel alloc] initWithFrame: frame];
    label.textAlignment - UITextAlignmentCenter;
    label.text = @"Hello World";
    label.font = [UIFont boldSystemFontOfSize: 40.0];
    label.textColor = [UIColor colorWithRed: 255.0/255.0 green: 255.0/255.0 blue: 255.0/255.0 alpha: 1.0];
    label.backgroundColor=[UIColor clearColor];
    [self addSubview: label];
    [label release];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
    // Release anything that's not essential, such as cached data
}


- (void)dealloc {
    [super dealloc];
}

@end

TESTAppDelegate.h
CODE
//
//  TESTAppDelegate.h
//  TEST
ç

TESTAppDelegate.m
CODE
//
//  TESTAppDelegate.m
//  TEST
//
//  Created by Aaron Sky on 6/14/08.
//  Copyright __MyCompanyName__ 2008. All rights reserved.
//

#import "TESTAppDelegate.h"
#import "TESTViewController.h"

@implementation TESTAppDelegate

@synthesize window;
@synthesize viewController;


- (void)applicationDidFinishLaunching:(UIApplication *)application {    
    
    self.window=[[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    self.viewController=[[[TESTViewController alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]] autorelease];
    [window addSubview:viewController];
    [TESTViewController DispHelloWorld];
    [window makeKeyAndVisible];
}


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


@end

main.m
CODE
//
//  main.m
//  TEST
//
//  Created by Aaron Sky on 6/14/08.
//  Copyright __MyCompanyName__ 2008. All rights reserved.
//

#import <UIKit/UIKit.h>

int main(int argc, char *argv[]) {
    
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    int retVal = UIApplicationMain(argc, argv, nil, nil);
    [pool release];
    return retVal;
}
User is offlineProfile CardPM

Go to the top of the page


sagganitra
post 23 Jun, 2008 - 03:14 AM
Post #2


New D.I.C Head

*
Joined: 23 Jun, 2008
Posts: 3


My Contributions


what do you wish to do.......
please first read documentation and examples at developer.apple.com/iphone. and then come for asking pecific questions


QUOTE(polymath @ 14 Jun, 2008 - 05:38 PM) *

just learning this one, looking for some support for my hello world program.

it has a few files:

1. TESTViewController.h

2. TESTViewController.m

3. TESTAppDelegate.h

4. TESTAppDelegate.m

5. main.m

TESTViewController.h
CODE

//
//  TESTViewController.h
//  TEST
//
//  Created by Aaron Sky on 6/14/08.
//  Copyright __MyCompanyName__ 2008. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface TESTViewController : UIViewController {

}

@end

TESTViewController.m
CODE
//
//  TESTAppDelegate.m
//  TEST
//
//  Created by Aaron Sky on 6/14/08.
//  Copyright __MyCompanyName__ 2008. All rights reserved.
//

#import "TESTViewController.h"

@implementation TESTViewController

/*
Implement loadView if you want to create a view hierarchy programmatically
- (void)loadView {
}
*/

/*
Implement viewDidLoad if you need to do additional setup after loading the view.
- (void)viewDidLoad {
    [super viewDidLoad];
}
*/

-(void)DispHelloWorld
{
    int  lmargin=0;
    int height=40;
    int width=320;
    int tmargin=40;
    CGRect frame = CGRectMake(lmargin, tmargin, width, height);
    UILabel *label = [[UILabel alloc] initWithFrame: frame];
    label.textAlignment - UITextAlignmentCenter;
    label.text = @"Hello World";
    label.font = [UIFont boldSystemFontOfSize: 40.0];
    label.textColor = [UIColor colorWithRed: 255.0/255.0 green: 255.0/255.0 blue: 255.0/255.0 alpha: 1.0];
    label.backgroundColor=[UIColor clearColor];
    [self addSubview: label];
    [label release];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
    // Release anything that's not essential, such as cached data
}


- (void)dealloc {
    [super dealloc];
}

@end

TESTAppDelegate.h
CODE
//
//  TESTAppDelegate.h
//  TEST
ç

TESTAppDelegate.m
CODE
//
//  TESTAppDelegate.m
//  TEST
//
//  Created by Aaron Sky on 6/14/08.
//  Copyright __MyCompanyName__ 2008. All rights reserved.
//

#import "TESTAppDelegate.h"
#import "TESTViewController.h"

@implementation TESTAppDelegate

@synthesize window;
@synthesize viewController;


- (void)applicationDidFinishLaunching:(UIApplication *)application {    
    
    self.window=[[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    self.viewController=[[[TESTViewController alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]] autorelease];
    [window addSubview:viewController];
    [TESTViewController DispHelloWorld];
    [window makeKeyAndVisible];
}


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


@end

main.m
CODE
//
//  main.m
//  TEST
//
//  Created by Aaron Sky on 6/14/08.
//  Copyright __MyCompanyName__ 2008. All rights reserved.
//

#import <UIKit/UIKit.h>

int main(int argc, char *argv[]) {
    
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    int retVal = UIApplicationMain(argc, argv, nil, nil);
    [pool release];
    return retVal;
}


User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 10/7/08 11:34PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month