zoukankan      html  css  js  c++  java
  • 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中的方法
    }
  • 相关阅读:
    Mongo简单查询总结
    将对象转换成Dictionary 字典
    C#调用NPOI组件导出Excel表格
    Lambda中的一些方法的总结
    LinQ总结
    简单的爬虫 一
    Python 中的注释规范
    在VM上配置一个能上网的网络设置
    Python 中新式类的内置方法
    Python 中的locals()
  • 原文地址:https://www.cnblogs.com/qingjoin/p/2563843.html
Copyright © 2011-2022 走看看