Today I learned the For loop and the method, the content is somewhat complex, but original aim in the later study easy to grasp, because the scope is broad, the use rate is high. So you'll get it when you practice.
———————— for Loop ——————————
For Loop concept:
One of the statements in the For Loop programming language for loop execution. The For loop is open, and its general form is: for (; <<span se-mark= "1" > Conditional expression >;) statement; Initialization is always an assignment statement, which is used to assign an initial value to a loop control variable; a conditional expression is a relational expression. It determines when to exit the loop; increment defines how the loop control variable changes after each loop. Between these three sections with ";" Separate. For example: for (i=1; i<=10; i++) statements; In the above example, I was given an initial value of 1, to determine whether I is less than or equal to 10, if the execution of the statement, then increased by 1. Then re-judge until the condition is false, i.e. i>10, the end loop.
The For statement is more flexible than the while statement and Do-while, and is a larger, more commonly used loop statement with a general syntax format of:
for (expression 1; expression 2; expression 3)
{
Loop body
}
Where the expression can be omitted, but the semicolon must not be omitted.
?—————————— Method ————————————————
Class methods and Instance methods
The instance method is that the class begins with a + instance method that is accessed with an instance object, which is a class rather than an instance, typically creating an object or a tool class.
In the instance method, the message sent to self and super based on the principle of inheritance is actually sent to self
Inside the class method, self is the class method of the other class, and sending a message to self in a class method can only be a class method.
When to use a class method, to create an instance to get a shared instance, or to get some common information about the class
IOS Learning Notes for loop method exercises--Lan Yi Education