Learning Objective-C and Xcode

本文介绍了Objective-C的基础概念和核心特性,包括语言符号、编译指令、类定义及继承等。Objective-C结合了C语言和SmallTalk的特点,几乎一切都是对象。文章通过创建DGCar类示例,展示了如何使用Xcode进行类文件的创建。

Objective-C is a combination of C and Small Talks

The trick is to understand the symbols and keywords

Understanding the Language Symbols

at the heart of Objective-C is C.

It's not important to know which are pure

{   his is the begin brace    Blocks are used to defin and surround a section of code and define its scope.

- (void)methodName It represents what type of information the method represents. 

* pointer 

[] Thease are called brackets and are used when sending a message to an Objective-C object 

@identify an Objective-C directive 

#import

- (void)logMesage

{

  NSString *hell =  @"Hello World!";

  NSLog(hello); 

}

@ is an Objective-C directive and is a quick way of defining a constant string object

MSLog method

Objective   is basis in Smalltalk

Pretty much everything is an object.

Objec

 

The @interface compiler directive

The identical object-oriented notion of inheritance works in Objective-C and many Cocoa touch classes.

remember the initial capital letter convention.

@interface NewSubclass : SuperClass

@symbol are called compiler directives.

tells the compiler that this section contains declarations of the variables and methods that will be fleshed out in the companion @implementation section .

a custom class needs far more infrastructure than what you'll be defining in the class files.

NSObject  the most fundamental classs in the Foundation framework.

Foundation, UIKit and other frameworks inherit from NSObject

Using Xcode to Create DGCar Class Files

choose Cocoa Touch Class in the left column, then Objective-C class in the top right group

specify hat this will be a subclass of NSObject.

 

#import <Foundation/Foundation.h>

@intarface DGCar : NSObject {

 

}

@end

 

转载于:https://www.cnblogs.com/yushunwu/archive/2012/07/23/2604362.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值