IOS Development Notes (1) Hello, world!

Time:2019-12-31

Hello,World 🙂

For a new language, according to the Convention, we will write a Hello, world! Next, we will start with Xcode installation and complete a simple hello, world application.

Install Xcode

Download and install Xcode through the app store, but sometimes the service of the app store is not stable in China, and the download fails. So if the app store fails to download for many times, you can use Xunlei store to download. However, Xunlei store is suspected of piracy. If you want to update Xcode later, you must download and install again.

Start writing a Hello, world app

Run Xcode from the dock or otherwise.

IOS Development Notes (1) Hello, world!

Create a new project through “create a new Xcode project”.

IOS Development Notes (1) Hello, world!

Then, choose IOS – Application – single view application and next.
The single view application here is a basic single page application template. It will create a simple MVC application. In addition, MVC is a very important design pattern in IOS development.

IOS Development Notes (1) Hello, world!

Procut Name: the name of the app.
Company identifier: if there is a domain name, you can fill it in, otherwise you only need to fill inedu.self
Here is class prefix. I filled in HelloWorld, so our controller class will be namedHelloWorldViewController
The devices option is used to select the appropriate devices. Here are three optionsiPhoneiPadUniversal。 Among them, universal can run on iPhone and iPad, while a universal application has independent UI on iPad and iPhone.
Continue to “next”, Xcode will ask us to choose the saved path. By the way, it is recommended to create a developer folder in the user directory to store Xcode project files.

IOS Development Notes (1) Hello, world!

Click “create”, and then the project is completed.

We can see the newly created project file directory as follows:

IOS Development Notes (1) Hello, world!

HelloWorldAppDelegate.[mh]We don’t have to worry about it here.
Main.storyboardView in our MVC application.
HelloWorldViewController.[mh]Code of controller in MVC.
Other documents can be ignored here and mentioned later.

Then we choose to open the main.storyboard file. Next, we will drag a label control to theHello World View Controllerin

IOS Development Notes (1) Hello, world!

Find the label control here and drag it to the view controller with the mouse held down.

IOS Development Notes (1) Hello, world!

stayHello World View ControllerClick to select the label control you just dragged in, and then select the attributes inspector tab on the top right(IOS Development Notes (1) Hello, world!) Here you can set the display content and format style of the label control.

IOS Development Notes (1) Hello, world!

Then openIOS Development Notes (1) Hello, world! Assistant editor

You can see that there is an extra column in Xcode interface, and then open it in a new columnHelloWorldViewController.m IOS Development Notes (1) Hello, world!

Now hold down the control key and drag the label controlHelloWorldViewController.mMedium@interface HelloWorldViewController ()and@endIn the middle.

IOS Development Notes (1) Hello, world!

IOS Development Notes (1) Hello, world!

Fill in hellolabel in name and click Connect to finish.

So I got the followingHelloWorldViewController.m

#import "HelloWorldViewController.h"

@interface HelloWorldViewController ()
@property (weak, nonatomic) IBOutlet UILabel *helloLabel;

@end

@implementation HelloWorldViewController

- (void)viewDidLoad
{
    [super viewDidLoad];    
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

Next, weHelloWorldViewController.mAdd the following code after [super viewdidload] in the viewdidload method in

_helloLabel.text = @"Hello,World!";

Function

PressCmd + BRun (or click theIOS Development Notes (1) Hello, world!Button

Then you can see the running result in the IOS simulator: Hello, world!

IOS Development Notes (1) Hello, world!

Stop operation availableCmd+QClose the IOS emulator or click the stop button on the top left of the Xcode interface.

So far, a simple HelloWorld application has been developed.


Some IOS development resources (update from time to time):

  1. Chinese IOS development related blog list
  2. Objc China – a foreign excellent Internet Journal of IOS development, this is a self translated version by netizens.
  3. “Objective-C programming” Douban link – suitable for beginners to see.
  4. Appcoda – a good foreign Tutorial Station, no need to climb the wall

Recommended Today

PHP realizes UnionPay business H5 payment

UnionPay business H5 payment interface document: document address 1: H5 payment interface address: 1: Alipay payment Test address: http://58.247.0.18:29015/v1/netpay/trade/h5-pay Official address: https://api-mop.chinaums.com/ 2: UnionPay payment Test address: http://58.247.0.18:29015/v1/netpay/uac/order Official address: https://api-mop.chinaums.com/ 2: Basic parameters required by the interface The interface uses get parameters. After the interface parameters are directly put into the interface address, the […]