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中的方法
    }
  • 相关阅读:
    ssh 无密码互通
    React之jsx转js
    分布式事务参考
    js跨域解决方案
    idea编译时JDK版本变化
    计数算法
    Rocketmq消息持久化
    rocketmq安装
    nginx高可用配置
    nginx负载均衡设置
  • 原文地址:https://www.cnblogs.com/qingjoin/p/2563843.html
Copyright © 2011-2022 走看看