objective-c学习 day-01(C部分)

本文介绍了C语言的基础知识,包括C语言的特点、Objective-C的特性、如何安装苹果开发者工具Xcode,以及C语言中变量声明、条件判断等基本语法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

getting start with C:

  •     C programmers write code in the C language, and a C compiler converts the C code into machine code.
  •     The Objective-C programming language is based on C, but it adds support for object-oriented programming.

Installing Apple's developer tools

    The main application that you will need is called Xcode.

  1.     Select Application from the OS X section, then choose Command Line Tool.

    2.    

    3.    

    4.    You can see and set the different options for code completion in Xcode's preferences. Select Xcode -->Preferences and then open the Text Editing preference.

 

Ⅱ.How Programming Works

    In a program, you create a new variable by declaring its type and name.    

  float weight;

    Here is an overview of the commonly used types:

    short, int, long, float, double, char, pointer, struct BOOL
  •     if/else:

        In C, it was decided that 0 would represent false, and anything that is not zero would be considered true.

if(condition){
    //Execute this code if the conditional evaluates to true
}else{
    //Execute this code if the conditional evaluates to false
}
  •     Boolean variables

        Too use BOOL in a C function, like main(), you would need to include in your program the file where this type is defined:

        

#include <objc/objc.h>
  • challenge:
int i = 20;
int j = 10;
int
k = (i > j) ? 10 : 5;

    ===>

int i = 20;
int j = 10;
if (i>j)
{
    int k = 10;
}else{
    int k = 5;
}

转载于:https://www.cnblogs.com/binbinyelling/p/3507315.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值