What will we learn?
- IOS Programming Courses with Swift / Series 1 ( Data Types )
Requirements:
- Notepad+
- IOS Operating System
- Xcode
Difficulty Level:
- Normal Level
Let's Start the Course :
Data Types
Text-Based Types
We will consider the data types used to store text-based expressions under the category of textual types. Then, as understood, the data types used to store text-based expressions.
String Data Type
It is the type of data stored in text-based expressions. It is possible to store a numeric data in a variable of type String. However, the numerical data we store will be stored in text base. It is not possible to do numeric operations (addition, subtraction.... ) on numeric stuff stored in "string" type. If we want to do a floating-point operation in a "string" variable, we will have to transform this variable into a numeric type by subjecting it to a "type conversion" which we will learn later.
If we want to assign a value to a text-based variable , we need to type the value to be assigned in double quotation marks ("").
var text1:String
var text2:String = "Utopian"
In the following sections I will show you how to handle string data more than once. However, the most basic operation is to learn how to combine two string expressions. In the following example, we see the concatenation of two string data. The concatenation of string expressions is called the concatenation of string data.
var name:String = "Kingmaggot"
"Hello " + name
If we repeat the important point here, the string expression is the concatenation of strings.
Character Data Type
A text-based variable is a type that can store only one character, even though it is a type. The character we keep can be a letter , a digit, or a punctuation. The information below about text-based data types is key. You will understand better what I mean about the series we will learn in the following articles, and we will relate this information to another information, and we will open an important door.
Since it is character data type, textual data type, the string type, just as in our data collection process that are subject to the merging process will be performed. In the following example, by assigning the letters "U", "t", "o", "p", "i", "a" ,"n" to K1, k2 , k3 , k4, K5,K6,K7 respectively, we obtained utupian data by adding these characters to the collection process.
var k1,k2,k3,k4,k5,k6,k7:String
k1 = "U"
k2 = "t"
k3 = "o"
k4 = "p"
k5 = "i"
k6 = "a"
k7 = "n"
//result -->> Utopian
The latest information we need to know about the character data type two-byte data type.
var character1: Character
var character2: Character = "!"
Real Number Types
Variable types that can store decimal numbers. Real number types include not only decimal but also integer numbers. When we want to keep decimal numbers in the variable, integer types such as integer are insufficient. The data types we need to refer to here should be "float" or "double".
var DecimalNumber1:Float = 10.2
var DecimalNumber2:Double = 5.5
If there are any remaining divisions we will make in real number types, it will be shown.
var Number1:Float = 19.3
var Number2:Double = 3
Number1 / Number2
Logical Types
It is the data type that stores only one of the values 0 OR 1, which are the two basic characters of the machine language. The data type that occupies the minimum amount of memory is also logical types. In programming , the value 0 is false and the value 1 is true.
We can understand the absence of ambiguity in programming from logical data types. If we move through the objects we encounter in everyday life, let's think of a window. With programming logic, this window is either open or closed. This means that the window is semi-open or intermittent. In this context, logical data types can be used in certain cases. In addition, we will see that the type of logical data that we will learn after a while is not an alternative type of "bool" data type, The type of logical data that occupies the least space in memory. The reason is that it can only get "true" or "false".
Bool Data Type
it is the data type that can store only one of the "true" or "false" values. Takes up space in bytes. It is usually used in two possibilities: "military status , married - single, female - male". There is no alternative to the "bool" data type in the logical data types I just mentioned.
TIP Transformation
Although we have learned the data types, this information is not enough. In particular, there will be some problems that we will encounter when we go to "Xcode" projects. The most classic of these problems is when we want to print numeric data anywhere on the screen. If we want to print a numeric expression on a control, we may need to convert it to a string type and print it. We will also need to apply for "tip" conversion. In addition to translating a numeric data into a string, we also need to convert a numeric expression into a numeric data type to a mathematical operation.
If we go over one example , we will have two variables, as follows. One of them will hide the name information, the other will hide the age information. Let's put these two data into a textual collection, that is, a concatenation process. As we see below, when we define both data As "String", we get the result we want. This is not a logical way to store age information in a string variable. When we store age information in a variable of type int, age information is "string" and there is no error in the collection process.
var name:String = " Kingmaggot "
var old:Int = 32
name + old.description + " he's Old."
//result --> Kingmaggot 32 he's Old
Fixed Description
We can change the value we assign to a variable in the next line as much as we want. In some cases, we may want to assign only one value to the variable we define and not change those values that are assigned later. For example, the number "PI" can be given. In such cases, we must define a constant instead of a variable.
Constant definition has only 1 difference according to variable definition. This difference is the use of "let" instead of "var".
let date_of_birth:Int = 1986
We need to know about this. We cannot take any action that would attempt to change the value of this constant , whether it is constant , numeric , or textual.
What Have We Learned ?
In this section, we learn how to use data consistency, data types with each other, and how to use these types of VI. The information we have learned in this section will be used in most of the following sections. In this respect, we have left behind an extremely important part.
For the rest of the article, follow our series.
Series :
1 - IOS Programming Courses with Swift / Series 1 #1
Posted on Utopian.io - Rewarding Open Source Contributors
Your contribution cannot be approved because it does not follow the Utopian Rules.
Related Rule:
Suggestions:
You can contact us on Discord.
[utopian-moderator]
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Hey @roj, I just gave you a tip for your hard work on moderation. Upvote this comment to support the utopian moderators and increase your future rewards!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Congratulations @kingmaggot! You received a personal award!
Click here to view your Board
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Congratulations @kingmaggot! You received a personal award!
You can view your badges on your Steem Board and compare to others on the Steem Ranking
Vote for @Steemitboard as a witness to get one more award and increased upvotes!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit