Understand everything about iOS development language in one article!

Understand everything about iOS development language in one article!

Preface

What are the iOS development languages? What are the main OS development languages? How to learn iOS development languages? Today we will focus on:

iOS development languages ​​mainly include: C language basics, Object-C programming, Swift, and detailed explanation of UIKit framework. I will not introduce them in detail in the project stage here.

C language basics C language is the basis of development language. It is the most commonly used programming language and is most commonly used to write computer programs.

Object-C programming Object-C is a general-purpose high-level programming language that is expanded on the basis of C language by adding object-oriented features.

Swift is a new language developed by Apple, and its purpose is to replace OC. I am also learning it. My biggest feeling is its simplicity and high efficiency. Detailed explanation of UIKit framework UIKit framework is the most basic framework in iPhone application development, and it is also the most commonly used and important framework.

The languages ​​are basically the same, they just use a different way of writing. It can even be said that the programming ideas are basically the same, they just use a different way of expression.

The most basic header file

The most basic

Header files and implementation files in OC

  • .h files are similar to .h files in C++
  • .m files are similar to .cpp files

The functions of header files are similar, declaring some functions, methods, properties or variables, and their functions are to provide interfaces.

Swift is different, there is no header file!! Just use it directly.

All implementation files have the suffix .swift. C++ imports header files using #include. OC imports header files using #include and #import, but generally we use #import, for example #import "ViewController.h"

Because #import imports the same header file multiple times and only imports it once (already imported files will be ignored), preventing duplicate imports

Another usage of OC is @class class name, which tells the compiler that this is a class and does not care about its internal details. This improves efficiency and prevents circular references to header files. Of course, you cannot access the internal details of this class.

Swift also needs to import some frameworks. Just import them directly without #, for example, import Foundation

Basic data types

Next, let's look at the basic data types. I'll talk about some of the more commonly used ones, and I won't talk about C++.

Many data types in Objective-C have the NS prefix. This is because Objective-C was developed by NextStep, the company that Jobs founded after he left Apple for the first time.

I just used some simple and straightforward ways to create data types, but there are many other ways to create them.

I have only introduced some of the more commonly used types, of course there are many similarities to C++:

For example, NSInteger, the unsigned version is NSUInteger

NSString, NSArray, NSDictionary are immutable types. Mutable types need to be added with Mutable, such as NSMutableString, NSMutableArray.

There are some other types such as NSNumber digital type, which can wrap int, float, double, etc.

Next, let’s look at Swift

Swift’s data types are similar, just Int, Float, Double, String, etc., but using them is so cool that it’s hard to describe it in one word.

Because Swift has type inference, and it’s awesome!!

For example, var str = @"hello world"

The compiler will automatically infer that str is of type String

In Swift, types are generally declared using let and var. Let means defining constants, while var means defining variables.

var a = 1 infers a to be Int. Of course, you can also write the type var a: Int = 1

In Swift, you can omit the semicolon, but if you want to define two variables on the same line, you must separate them.

Of course, Swift has a lot more things than OC, such as tuples, closures, etc., many things that are very simple to use

hello world

Next, let’s start with the simplest one—hello world

  • C++
  • OC
  • Swift

Swift is so concise that you can run it directly

Many OC syntaxes are also close to C++

At least many methods are written very long, but they look very clear, so I won’t go into details here.

Since I'm learning Swift recently, let me introduce some simple Swift statements and how concise they are.

for Statement

0 . . < 4 means 0 ≤ i < 4

0. . . 4 can also mean 0 ≤ i ≤ 4

Closures

All algorithms are finally simplified into one> This>

It can be regarded as a super concise version of a closure. It originally looked like this

Yes, that string finally became a>

These are just the tip of the iceberg, just one vote in the stock market

Learning Swift gives me the feeling of simplicity, freshness and refreshing!

How to quickly learn the introductory language of iOS?

The author lists the knowledge that entry-level iOS developers need to master to help you learn iOS development from scratch.

1. Basic CS knowledge

Having a basic understanding of data structures and algorithms will definitely prevent novice developers from writing messy code. So for novices, Danai IOS training experts recommend watching the Harvard CS50 course on Youtube as a starting point. These courses are easy to understand and very interesting.

2. Swift or Objective-C?

You don't need to be able to write a technical blog in either language, or to teach a class, but you should be able to program in at least one of them without looking up the syntax too often. APIs are another story, especially in iOS, where frameworks are updated every year and many methods are often deprecated. You need to be able to write classes, structures, loops, functions (classes and instances), assign variables, and evaluate expressions on your own.

Swift is still very new, and unless you join a company that has frequent project changes, you will basically have to use Objective-C. Many companies are deciding to switch to Swift, and if you know Swift, it won't be particularly difficult to find a job. The important thing is to be proficient enough in the language you choose, and at least be familiar enough with the other one to read the code.

3. Framework and API

Dana IOS training experts do not think that you must be able to recite all iOS APIs by heart, but you need to know clearly where to start.

  1. UIKit (UITableView, UIButton, UINavigationController, GestureRecognizers)
  2. Interface Builder (Storyboards, Segues, and the odd .xib)
  3. Foundation types (NSArray, NSDictionary, NSString) and their Swift counterparts (Array, Dictionary and String) HTTP API (NSURLSession, basic REST API concepts, JSON parsing with NSJSONSerialization)
  4. Grand Central Dispatch (GCD, NSOperationQueue)
  5. Data persistence (NSCoding, NSUserDefaults, CoreData)
  6. Memory management (what are circular references and the basic principles of ARC)

4. Design Patterns in Development

Patterns are important, they make your development easier and your code clearer. Make sure you understand the basic design patterns, which are widely used in the iOS framework, and you are unlikely to make much without knowing them.

  • Proxy Mode
  • Model-View-Controller Pattern
  • inherit
  • Singleton Pattern

5. Familiar with the development environment

If you don't have a Mac, get one! If you don't have an iOS device, get one! It's hard to develop for a device if you haven't used it or are unfamiliar with it. Likewise, it's hard to write code if you don't have a Mac.

6. UX/UI

Generally speaking, UX (user experience) and UI (interface) are the responsibility of designers, but you should also understand Apple's human-computer interaction guidelines. You should understand the difference between product prototypes and wireframes, and how to use them in the development process.

7. Tools

You should be familiar with some common development tools.

  • Xcode
  • Git version control
  • JIRA or Bugzilla
  • CocoaPods

8. Works

Actions speak louder than words. If you want to ace the interview, put together some simple apps (or better yet, publish them on the AppStore). Show that you can complete a project on your own.

Summarize

I want to briefly introduce OC and Swift so that everyone can understand these two languages. iOS development is based on these two languages. Both OC and Swift have many interesting syntaxes waiting for us to discover.

<<:  Xposed Framework first Oreo version released: all Oreo devices can use it

>>:  Compared to Jobs, Apple under Cook is more and more prone to delaying its delivery

Recommend

Asian badger: Lose six pounds in one sleep, how many people envy it?

"During the Jingzhe period, the Yang energy ...

New brands use content IP as endorsement

Brands can find celebrities to endorse their prod...

Get APP product experience: Has the trend of knowledge services arrived?

Lao Luo said in a recent program that people'...

Redhat Red Hat RHCE8.0 Certification System Course

Introduction to Redhat RHCE8.0 certification syst...

Is the story of “The Crow and the Pitcher” true?

Is the story of “The Crow and the Pitcher” true? ...

Build a ToB market operation system from 0 to 1!

Editor's note: In previous articles, the auth...

Wearing AR glasses to assemble the Chinese space station, super cool

Not long ago, several students from Tsinghua Univ...