IOS Tutorial -- 1) Objective-C Basics
2013-06-09 17:34
162 查看
Objects and classes
A class consists primarily of two things: variables that can store data and methods
that can perform operations.
Subclasses
Classes can also inherit functionality from an existing class
Instance and class variables
Changing the value of an instance variable in one object
will not affect the value of the same variable in all the other objects of that class.
Conversely, only a single copy of a class variable exists. If you change the value of
a class variable from one object, the value of that variable will change for all the
objects of that class
Accessor methods
Accessor methods, sometimes called getters and setters, are usually fairly simple
methods used to get and set instance variables in a class
Class methods
Class methods (also known as static methods) are methods that are associated directly
with the class rather than the object instance
Events and messages
An event is a message generated by the user interacting with your application’s
controls. For instance, if you tap the screen of your iOS device, this generates a UI
event in your application that is passed via a message from the application to an
object that has been delegated to deal with that specific type of event
Protocols
A protocol definition declares methods that any class can implement. If your class
declares that it abides by a particular protocol definition, you are announcing that
you have implemented the minimum mandatory methods declared in the protocol
definition, and may optionally have implemented some nonmandatory methods
Delegate classes
A delegate class is a class that implements a protocol for handling events.
Event loop
The main event loop is the principal control loop for your application.
Reference Counting
Reference counting is a form of garbage collection, which counts the number of references
to an object (or portion of memory) and frees the associated memory when the
number of references reaches zero. The main advantage of reference counting over
"classic" garbage collection is that memory is freed as soon as it is no longer in use
A class consists primarily of two things: variables that can store data and methods
that can perform operations.
Subclasses
Classes can also inherit functionality from an existing class
Instance and class variables
Changing the value of an instance variable in one object
will not affect the value of the same variable in all the other objects of that class.
Conversely, only a single copy of a class variable exists. If you change the value of
a class variable from one object, the value of that variable will change for all the
objects of that class
Accessor methods
Accessor methods, sometimes called getters and setters, are usually fairly simple
methods used to get and set instance variables in a class
Class methods
Class methods (also known as static methods) are methods that are associated directly
with the class rather than the object instance
Events and messages
An event is a message generated by the user interacting with your application’s
controls. For instance, if you tap the screen of your iOS device, this generates a UI
event in your application that is passed via a message from the application to an
object that has been delegated to deal with that specific type of event
Protocols
A protocol definition declares methods that any class can implement. If your class
declares that it abides by a particular protocol definition, you are announcing that
you have implemented the minimum mandatory methods declared in the protocol
definition, and may optionally have implemented some nonmandatory methods
Delegate classes
A delegate class is a class that implements a protocol for handling events.
Event loop
The main event loop is the principal control loop for your application.
Reference Counting
Reference counting is a form of garbage collection, which counts the number of references
to an object (or portion of memory) and frees the associated memory when the
number of references reaches zero. The main advantage of reference counting over
"classic" garbage collection is that memory is freed as soon as it is no longer in use
相关文章推荐
- __block的两种核心用法(摘自iOS 7 Programming Fundamentals: Objective-C, Xcode, and Cocoa Basics)
- Your first iOS app(2)——Tutorial:Basics
- Entity Framework Tutorial Basics(42):Colored Entity
- Core Text Tutorial for iOS: Making a Magazine App(中文)
- IOS基础:Objective-C 字符串处理
- 【Objective-C】02-Objective-C学习及iOS开发的准备
- Objective-C语法之Objective-C语言和iOS系统(简介,语法,系统结构)
- Objective-C 对象(内容根据iOS编程编写)
- IOS 开发学习(1): 学习纲领以及Objective-C 基本语法学习
- 【iOS】巧用 LLVM 特性: Objective-C Class Properties 解耦
- IOS/OSX MAC C++与objective-c混合编程 objective-c++
- iOS开发:详解Objective-C runtime
- Objective-C ,ios,iphone开发基础:picker控件详解与使用,(实现省市的二级联动)
- Objective-C ,ios,iphone开发基础:快速实现一个简单的图片查看器
- iOS开发系列--Objective-C之协议、代码块、分类
- Core Data Tutorial for iOS: Getting Started
- Objective-C编码规范:26个方面解决iOS开发问题
- 【学习ios之路:Objective-C】继承,便利构造器.NSString应用
- iOS: 在Object-C中监听javascript事件( Javascript communicating back with Objective-C code)
- 【iOS】objective-c2.0之基本数据类型