IOS Tutorial — 1) Objective-C Basics

來源:互聯網
上載者:User

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

 

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.