concept number in category ios

appears as: numbers, number, numbers, number, The number, A number
Hello Swift!: iOS app programming for kids and other beginners

This is an excerpt from Manning's book Hello Swift!: iOS app programming for kids and other beginners.

Wait a minute—I thought variables were just for storing numbers. How can I be using one to store a name?

Figure 3.6. Using an operator with numbers in the Playground
let x: Int = 3                               #1
if x == 1 {
    print("You entered One, didn't you?")
} else if x == 2 {
    print("You entered Two, didn't you?")
} else if x == 3 {
    print("You entered Three, didn't you?")
} else if x == 4 {
    print("You entered Four, didn't you?")
} else {
    print("Uh-oh, you did not enter the number 1, 2, 3, or 4!")
}

Loops are constructs provided by Swift and other programming languages that allow you to run the same block of code a number of times.

Anyone Can Create an App: Beginning iPhone and iPad programming

This is an excerpt from Manning's book Anyone Can Create an App: Beginning iPhone and iPad programming.

Regardless of whether it’s been a month or a few decades since you were in a math class, you probably remember that there are different types of numbers: whole numbers, decimals, integers, and so on. If you’re like me, you never thought you would need this knowledge outside of math class, but guess what? You now get to use that knowledge again for creating apps, even though you probably thought at the time I’m never going to use this (thanks, Mr. Bellamy).

The first type of number we’ll discuss is an integer. In Swift, we use the variable type Int for integers, which are whole numbers (numbers without decimal places). An Int can store big numbers like –2,147,483,648 or 2,147,483,648. That’s right: an Int can be a positive number, negative number, or even zero.

The next control statement that we’re going to talk about is called a switch statement. If you think back to section 9.1, when we talked about the if statement, we evaluated certain conditions by saying something like “If x is less than y, or if y is less than z.” What if I wanted to know whether a number was prime or not (prime numbers are those that can’t be divided by any number other than 1)? I could write a lot of if statements to say something along the lines of “if x==3, or if x==5, or if x==7” and so on, but that would be a lot of if statements. There’s a much easier way to accomplish this check, and that is with a switch statement. The switch statement allows you to compare a value to multiple other values. The essence of the switch statement is as follows:

10.3.3. Step 3: Create a variable to capture the number guessed: numberGuessed

You need to create a variable that can store the number that the user guessed. This is different from the label you created on the storyboard—the label is text to show the user what they guessed. You need an Int variable to store a number. Remember that you can store variables as different types, such as an Int for whole numbers (numbers without decimals), a String for words or even sentences, and a Double for numbers with decimals. The numberGuessed variable will start with the number 3, since that’s what the label states, but you could start (or initialize) the variable to any number you wanted.

Objective-C Fundamentals

This is an excerpt from Manning's book Objective-C Fundamentals.

Cocoa Touch consists of a number of frameworks (commonly called kits). A framework is a collection of classes that are grouped together by a common purpose or task. The two main frameworks you use in iPhone applications are Foundation Kit and UIKit. Foundation Kit is a collection of nongraphical system classes consisting of data structures, networking, file IO, date, time, and string-handling functions, and UIKit is a framework designed to help develop GUIs with rich animations.

Xcode can compile C (.c) or C++ (.cpp) source code in an iPhone project just as easily as it can compile Objective-C (.m) files. Simply add the files to your project and allow Xcode to build your project as normal. A number of the key frameworks in iOS, such as Core Graphics, are C-based APIs, so you’re already familiar with integrating code developed in C or C++ with an Objective-C project.

Unlike Mac OS X, though, iOS doesn’t provide a C-based API for creating GUIs (there’s no equivalent of Carbon). This means that unless you’re interested in developing a completely custom UI with OpenGL (another C-based API), your use of C or C++ source code will probably be restricted to behind-the-scenes logic, which will then be interfaced to a UI written in Objective-C. This isn’t a bad approach if you want to share a core set of logic across a number of platforms that support development in C or C++, such as iOS, Android, Symbian, and Windows Mobile. You can develop your core logic with C or C++ and then wrap a platform-specific UI layer around it for each platform you want to support.