IOS 7, 30 days proficient in iPhone mobile phone programming, 14th days image browser

Source: Internet
Author: User
Tags constant definition

ScrollView Control

(1) constant definition const

The const in OC can replace macro definition # define.

(1.1) can be read within the constant defined in the program. For example:

Const int a = 3;

Int B = 0;

A = B; // invalid compilation error.

B = a; // valid

(1.2) when using const to define a constant, you must determine that the constant object initializes data.

Const int a = 3; // valid

Const int B; // invalid, resulting in compilation errors

(1.3) when the const constant is referenced in the external link file, after the extern is added, a becomes an object with an external link, and its address has the external link feature.

Extern const int a; // valid

Extern const int B = 3; // The constant cannot be assigned again.

Using const saves more memory space than # define. in the program, const only performs one copy of data, while # define defines the number of objects and the number of data copies.

# Defien a 3; // macro

Const int B = 3; // B is not put into memory at this time

Int I = a; // macro replacement, memory allocation

Int j = B; // memory allocation, which will not be allocated later

Int I = a; // macro replacement, memory allocation again

Int J = B; // no memory is allocated.

(2) array data type definition NSArray

NSArray is an array data class in the Foundation framework. NSArray is like a traditional array in C language. It is usually used in defining integer data types to obtain data storage space in memory. The NSArray object is used to store the subview in the view.

// Create an array variable object and define the "subview" of the scrolling View"

NSArray * subviews = [scrollView1 subviews];

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.