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

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;
}
posted @ 2014-01-06 15:33  zhanghb_  阅读(122)  评论(0)    收藏  举报