iPhone 开发教程(斯坦福大学)

iPhone 开发教程(斯坦福大学)

5 (4人评价)
  • 课时:(28)

  • 学员:(670)

  • 浏览:(29422)

  • 加入课程

各种基础的类,功能,对象和实例的介绍的笔记

相关课时: 笔记详情:

Class is a blueprint for instances.

Instance: a specific allocation of a class

Method: a function that an object knows how to perform

Instance Variable(or ''ivar"): a specific piece of data belonging to an object.

Encapsulation: keep implementation private and separate from interface

Polymorphism: different objects, same interface

Inheritance: hierarchical organization, share code, customize or extend behaviors.

Objective-C

Strict superset of C

  • Mix C with ObjC
  • Or even C++ with ObjC (usually referrend to as ObjC++)

A very simple language, but some new syntax

Single inheritance, classes inherit from one and only one superclass

Protocols define behavior that cross classes

Dynamic runtime

Loosely typed, if you'd like

Classes and Objects

  • Classes declare state and behavior
  • State (data) is maintained using instance variables
  • Behavior is implemented using methods
  • Instance variables typically hidden Accessible only using getter/setter methods

Dot Syntax

convenient shorthand for invoking accessor methods

float height = [person height];

foat height = person.height;

[person setHeight:newHeight];

person.height = newHeight;

[[person child] setHeight:newHeight];

// exactly the same as

person.child.height = newHeight;

Dynamic and static typing

  • Dynamically-typed object        

      id anObject

  • Statically-typed object

      Person *anObject

 Objects represented in format strings using %@

 

0 0

你感兴趣的课程

移动开发 IOS开发入门教程
17万+浏览/ 7238学员/ 4.1评分
免费
7万+浏览/ 803学员/ 4.8评分
免费
6万+浏览/ 241学员/ 4评分
免费