• 【ObjectiveC】系列01:入门训练


    打开Xcode,选择Command Line Tool,类型选择Foundation;

    其中.m为源文件;

    例1:

    #import <Foundation/Foundation.h>
    
    int main(int argc, const char * argv[])
    {
        NSLog(@"Hello, World!");
        return 0;
    }

    例2:BOOL与NSString的使用

    #import <Foundation/Foundation.h>
    BOOL isDiff(int a, int b)
    {
        if(a==b)
        {
            return (NO);
        }
        else
        {
            return (YES);
        }
    }
    
    NSString* boolStr(BOOL b)
    {
        if (b == NO) {
            return (@"NO");
        } else {
            return (@"YES");
        }
    }
    int main(int argc, const char * argv[])
    {
        BOOL bRet;
        bRet = isDiff(5, 5);//NO
        NSLog(@"are %d and %d different?:%@", 5, 5, boolStr(bRet));//NO
        
        bRet = isDiff(23, 42);
        NSLog(@"are %d and %d different?:%@", 23, 42, boolStr(bRet));
        
        return 0;
    }
  • 相关阅读:
    搜索1011
    搜索1008(二分)
    贪心算法专题总结
    贪心算法1002
    c++笔记
    贪心算法1017
    贪心算法1008
    贪心算法1013
    Ubuntu中 sudo update与sudo upgrade的作用及区别
    requirejs 扩展,支持脚本资源预加载
  • 原文地址:https://www.cnblogs.com/elesos/p/2761906.html
Copyright © 2020-2023  润新知