Sportica   Sportica

objc--实现简单的输出,

 // test.h 中的头文件
#import <UIKit/UIKit.h>

@interface test : UIViewController


-(void)temp:(int)value1 :(int) value2;
@end

/******************************/



// test.m文件 用来写一个方法
#import "test.h"

@interface test ()

@end

@implementation test

-(void)temp:(int)value1 :(int) value2
{
    int temp;
    if(value1<value2)
    {
        temp = value2;
        value2 = value1;
        value1 = temp;
    }
    NSLog(@"%i ,%i\n",value1,value2);
    
}

@end

/****************************/
// 项目中的一个 ViewController.m 文件
#import "ViewController.h"
#import "test.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)viewDidUnload
{
    [self setButtonpress:nil];
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
- (void)dealloc {
    [buttonpress release];
}


- (IBAction)buttonpresstxt:(id)sender {
    /*test printf*/
    int     integerVar = 10;
    float   floatingVar = 332.45;
    double  doubleVar = 8.44e+21;
    char    charVar = 'w';
    
    NSLog(@"integerVar = %i",integerVar);
    NSLog(@"floatingVar = %0.2f",floatingVar);
    NSLog(@"doubleVar = %e",doubleVar);
    NSLog(@"doubleVar = %g",doubleVar);
    NSLog(@"charVar = %c",charVar);
    /*********************/

    test *_test = [[test alloc]init];
    [_test temp:20 : 36];     //调用test中的方法
}
posted @ 2012-06-26 15:59  qingjoin  阅读(279)  评论(0编辑  收藏  举报
  Sportica