60 minute introduction to IOS development


60 minute introduction to IOS development

This article is for beginners of IOS development who have programming experience in other languages (such as Java, C, PHP, JavaScript). The original intention is to let my colleagues know how to start developing IOS app in an hour. The learning objectives include:

  • Can use Xcode IDE, simulator
  • Ability to modify and debug existing IOS apps
  • Can create new modules in existing applications
  • Ability to create new applications
  • Can publish apps to app store

This article does not contain any advanced IOS development knowledge. Students who have learned IOS development should not read it. Students who have read this article should not read it again.

Not just learning a new language

People who have script development experience (such as JavaScript, PHP, shell) will feel that the learning curve of IOS development is higher than that of script language when they start to learn IOS development. Yes, this feeling is right. Because learning IOS development is not only about learning a new language, it includes:

  • A language: Objective-C
  • A framework: cocoa touch
  • An IDE: Xcode

Script language is not usually used to draw graphical interface and interact with people. If IOS doesn’t do graphical interface, it’s meaningless to process text operation database like script language.

So, in the past, I used to write other beginner’s tutorials, usually “XXX 15 minute tutorial”, while IOS took several times to write.

Environmental preparation

There must be Apple’s software environment for IOS development: Mac OS operating system, Objective-C compiler, device simulator, etc. the development tool does not have to use Xcode, as long as it is a source code editing tool (VIM, but not Xcode).

Mac OS

The easiest way to have a Mac OS environment is to find an apple computer, including iMac, macbook pro, MacBook Air, mac mini, but excluding Apple’s mobile devices (iPod touch, iPhone, iPad, ipad Mini, they are running IOS system, not Mac OS). Mac OS will be pre installed on apple computer when it leaves the factory. The latest version is Mac OS X 10.8, and the mainstream version is Mac OS X 10.6、Max OS X 10.7。

If you are shy, you can borrow one or go to Taobao to buy a second-hand one.

Black apple

When it comes to the introduction of IOS development, it seems that there is no way not to mention black apple. The so-called black apple is to install Mac OS on non Apple hardware after the transformation. This is against the DMCA act. More information about black apple can be found on Wiki

The price of apple computer is high, and the survival pressure of domestic software developers is great, so black apple also has some real existence in China, of course, there are also foreign countries.

Black apple is basically competent for IOS development, but there are some problems:

  • It’s illegal to install black apple
  • Apple will not pursue individual behavior, but will be despised by peers
  • Black apple is super hard to install, choose hardware. Even if the same model and batch are the same, it is possible that machine a is installed and machine B is not
  • The black apple system has some problems in use, such as driving the bug, restoring the blue screen in standby mode, and browsing the Internet
  • Black apple can’t upgrade at will. Maybe one upgrade of safari will cause the whole system to crash

Although the above will not directly affect Xcode’s code writing and simulator testing, Safari can’t turn the page when it’s written that he wants to check something online, which really affects his mood. So, if the wallet allows, it’s better to make an apple computer.

Xcode and simulator

Xcode can be downloaded free on Apple’s official website: Xcode download address

The IOS SDK and emulator are automatically installed when Xcode is installed.

Such a powerful IDE is free, which makes people happy.

Start with an off the shelf application

It’s very important to learn a new software development skill and be able to make a workable product at the first time, which is helpful to give myself positive motivation. When I was in college, I wanted to learn a new language many times, which often took half a month, and I was still immersed in the data type and grammar dictionary. I didn’t even make the first hello world.

This time, let’s start with an off the shelf application.


First, we download a sample code from the Apple Developer Center. I chose toolbarsearch.

At the end of this document, there are other websites where you can download open-source IOS products or code snippets, but I tried to find out that Apple sample code is the easiest to succeed.

The downloaded zip file is best saved in the “download” or “Manuscript” directory, because before Mac OS 10.8, some directories (such as / var / private / tmp) could not be seen in the finder, which can only be accessed through the finder’s “go to > go to folder” function.


There are three ways to open an IOS project

Double click the project file

Open the finder, enter the toolbarsearch directory just downloaded and unzipped, find the toolbarsearch.xcodeproj file, double-click it, Xcode will start automatically, and open this project

Select project in Xcode to open

  • When Xcode does not start (if Xcode has already started, press command Q to exit first). When Xcode is started, a welcome page of “welcome to Xcode” will pop up. Click the “open other” button in the lower left corner, find the toolbarsearch directory, double-click the toolbarsearch directory, or double-click the toolbarsearch.xcodeproj file

  • If Xcode is open, you can click file – > open, or file – > Open recent in its menu bar, and then select the item to open

Open from command line

Before Mac OS 10.8, some directories (such as / var / private / tmp) could not be found by clicking the mouse in the file > Open dialog box of finder and Xcode. At this time, they would be opened through the command line terminal.

Open the terminal and execute:

Parent directory of CD / toolbarsearch / toolbarsearch
open -a Xcode

Open – A is the system command of Mac OS. In addition to IOS projects, other projects can also be opened in this way.

Run the app you just downloaded

Click the run button in the upper left corner of Xcode (or press the common and R keys at the same time), Xcode will compile the source code and run the application in the simulator.

“Build succeeded” will be displayed on the screen. Otherwise, the failure displays “build failed” and does not start the simulator.


See “performed search using…” on the simulator Come on, let’s get rid of it.

  • Under the run button in the upper left corner of Xcode, there is a row of small buttons. The third one from left to right is a magnifying glass icon. When the mouse moves up, it will display “show the search navigator”. Click it, open the search interface, and enter “performed” in the find input box that appears below it

  • There is only one search result: toolbarsearchviewcontroller. M. click the highlighted “performed” string under the file name. The code editing area on the right will automatically open the file and scroll the screen so that the line containing “performed” appears in the middle of the editing area.

  • Modify the string in double quotation marks, change whatever you like, and then press “command s” to save.

Of course, these operations can also be done under the terminal through grep and vim.

Run the modified application

Press command r to run, see if you see the effect?

Yes, it’s so easy to modify an application.


Objective-C is the development language of Apple’s application software (including Mac OS app on Apple Computer and IOS app on mobile device). It is an object-oriented programming language.

Apple also provides a software, called interface builder, or IB for short, for visual interface making, just like using Dreamweaver to make web pages or visual basic to make desktop software. Later, IB was integrated into Xcode and became a part of Xcode. This document does not talk about IB, only Objective-C, because:

  • Basically, every book that talks about IOS development (paper book, e-book) has a large number of screenshots to teach how to use IB to develop IOS applications step by step, while there are not so many books that talk about Objective-C to develop applications.
  • IB can be used to draw interfaces, set control properties, and establish code and control relations intuitively and conveniently, but the business logic and data processing in the background still rely on Objective-C. it can be seen that whether IB is used or not, Objective-C cannot be bypassed.

Superset of C

Objective-C extends ANSI C and is a superset of C, that is to say:

  • Any C source program can be successfully compiled by Objective-C compiler without modification
  • Any C code can be directly used in Objective-C source program

In addition to the Smalltalk style of object-oriented syntax (to be discussed below), other non object-oriented syntax and data types are exactly the same as C, so this article will not go into details.
Take a classic Hello world example:

#import <Foundation/Foundation.h>
int main(int argc, char *argv[]){
        NSLog(@"Hello World!");
    return 0;

Isn’t it as if I have passed through the era of learning C language in my freshman year, which seems almost the same as C, right? Yes, because we haven’t used its object-oriented feature, ha ha!

The messaging syntax style of Smalltalk

The object-oriented syntax of Objective-C comes from Smalltalk, the message passing style. In terms of source code style, this is the biggest difference between C family language (including C / C + +, Java, PHP).

In the world of Java and C + +, we call a certain method of an object. In Objective-C, this is called sending a message to a type. This is not only a word game, but also their technical details are different.

In Java, the relationship between object and method is very strict. A method must belong to a class / object, otherwise compilation will report an error. In Objective-C, the relationship between type and message is relatively loose. Message processing will be determined dynamically at runtime. Sending a message to a type that it cannot process will only throw an exception and will not hang up.

[obj undefinedMethod];

Call undefined methods in the code (this is a common saying in the Java world. The professional way is to pass messages to obj objects that it can’t handle). Xcode will warn, but the compilation will succeed, and errors will occur when running. It will output an error like this:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSObject undefinedMethod]: unrecognized selector sent to instance 0x8871710'

OOP concept similar to Java

Some object-oriented concepts in Objective-C can also be found in Java (it can only be said that they are similar, not exactly the same). My readers are basically Java and PHP programmers. I will try to use the concept of Java as an analogy in the following.

Some people on Google Code have sorted out the corresponding tables of Java and Objective-C concepts and data types, as shown here

Character string

The string in Objective-C is enclosed by double quotation marks, and an @ sign is added before the quotation marks, for example:

title = @"Hello";
if(title == @"hello") {}

PHP programmers should note that single quotes cannot be used here, even if there is only one character. Objective-C is the same as Java and C. double quotation marks represent strings.

function call

As mentioned earlier, when object-oriented is not involved, it is exactly the same as C. Here are some examples of function calls:

Without parameters


Band parameters

NSLog(@"decrypted string: %@", str);

Passing messages to class / instance methods

Without parameters

[obj method];

Corresponding java version


With one parameter:

[counter increase:1];

Corresponding java version


With multiple parameters

For C family programmers, this is the most unacceptable and anti-human:

-(void) setcolortored: (float) red green: (float) green blue: (float) blue {...} // definition method
[myobj setcolortored: 1.0 green: 0.8 blue: 0.2]; // call method

Corresponding java version

public void setColorToRedGreenBlue(float red, float green, float blue) {...}
myObj.setColorToRedGreenBlue(1.0, 0.8, 0.2);

Message nesting

UINavigationBar *bar = [[[UINavigationBar alloc] init] autorelease];

Corresponding java version

Uinavigationbar = uinavigationbar. Alloc(). Init(). Autorelease(); // Java has no pointer, so the asterisk is removed


Interface and Implementation

Objective-C classes are divided into two parts: interface definition and implementation. The interface definition is placed in the header file, the file extension is. H, the implementation is placed in the implementation file, and the file extension is. M (there is also a. Mm extension, indicating mixed code of Objective-C and C + +).

Interface definitions can also be written in. M files, but it's best not to

It should be noted that the closest to the concept of Objective-C interface is the header file in C and C + +, which appears in pairs with implementation to declare the member variables and methods of a class. It is quite different from the interface concept of Java:

  • In Objective-C, there is only one implementation for interface, and 0-n implementations for java interface
  • In Objective-C, interface can define member properties, not in Java

In Objective-C, the interface concept similar to Java is protocol, which will be discussed later.

See the example:


@interface MyClass {
    int memberVar1;
    id  memberVar2;

-(return_type) instance_method1; 
-(return_type) instance_method2: (int) p1;
-(return_type) instance_method3: (int) p1 andPar: (int) p2;


@implementation MyClass {
    int memberVar3;

-(return_type) instance_method1 {
-(return_type) instance_method2: (int) p1 {
-(return_type) instance_method3: (int) p1 andPar: (int) p2 {

Interfaces and implementations start with @ interface, @ implementation, and end with @ end. The “@” symbol is a magic symbol in Objective-C.

Colon is also a part of method name. Method and method: are two different method names, not overload. The second one has parameters.

Java version corresponding to the above code:

public class MyClass {
    protected int memberVar1;
    protected pointer memberVar2;
    private int memberVar3;

    public (return_type) instance_method1() {

    public (return_type) instance_method2(int p1) {

    public (return_type) instance_method3andPar(int p1, int p2) {

Private and public methods

The methods written in the. H header file are all public. There is no concept of private methods in Objective-C (no egg for you, ha ha ha ha ha).

The official didn’t mention how Objective-C implements private methods. I checked stackovlow. The unified answer is that to achieve the effect of private methods, you can only rely on category. However, according to my test, even if category is used, you can’t prevent external code from calling this “private method”, but Xcode doesn’t support the automatic completion of “private method”, and there will be an alarm Notice that when running, it will succeed. It’s OK for you to know that. I won’t go into it here.

Variables and properties

Class method and instance method

Class method

Class methods are static methods in Java and PHP, which can be adjusted without instantiation. Class methods have a plus prefix.

Class definition

@interface MyClass
    +(void) sayHello;

@implementation MyClass

+(void) sayHello {
    NSLog(@"Hello, World");


[MyClass sayHello];
Example method

Instance method is a common method in Java and PHP, which can only be adjusted by instantiation. The instance method has a minus prefix.

Class definition

@interface MyClass : NSObject
-(void) sayHello;

@implementation MyClass

-(void) sayHello {
    NSLog(@"Hello, World");


mycls = [MyClass new];
[mycls sayHello];


Selector is a method pointer, similar to the dynamic method name in PHP:

class Hello {
    public function sayHello() {}

    public function test() {
        $fun_name = "sayHello";

In Objective-C, selector is mainly used to do two kinds of things:

Actions triggered by binding controls
@implementation DemoViewController
-(void) downbuttonpressed: (ID) sender {// method in response to "button pressed event"
    UIButton *button = (UIButton*)sender;
    [button setSelected:YES];

- (void)drawAnButton {
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; 
    btn.frame = _frame; 
    btn.tag = 1;
    btn.backgroundColor = [UIColor clearColor];
    [btn addTarget: self
         action: @selector(downButtonPressed:)
         Forcontrolevents: uicontroleventtouchupinside]; // when this button is pressed, the downbuttonpressed: method is triggered

Delay asynchronous execution

@implementation ETHotDealViewController
- (void)viewDidLoad {

    //Get data source
    HotDealDataSource *ds = [[HotDealDataSource alloc]init];
    [ds reload];
    _items = ds.items;

    [self performSelector: @selector(refreshTable)
          withObject: self
          Afterdelay: 0.5]; // delay 0.5 seconds to call refreshtable method

    [self.tableView reloadData];

In this example, the data source is obtained by asynchronously calling the HTTP interface of the server through the asihttp component. Refreshtable needs the data returned from the data source. If it is not delayed by 0.5 seconds, it will execute immediately. When the data is on the way, the page will become blank.


Inheritance is written in the interface definition. Syntax: the child class name is on the left, the parent class name is on the right, separated by colons.

@interface MyClass : NSObject

The corresponding java version is:

public class MyClass extends NSObject {


It’s the interface in Java and PHP.

Definition of agreement

The @ protocol keyword is used to define the protocol:

@protocol Printable

The corresponding java version is:

publilc interface Printable {
    public void print(String str);
Inheritance of agreement

The agreement itself can also inherit other agreements:

@protocol Printable <NSObject>

Corresponding java version:

public interface Printable extends NSObject {
    public void print (String str);
alternative method

Protocols can contain optional methods, as the name implies, which can be implemented without classes:

@protocol Printable

With the @ optional keyword added, when a class implements this protocol, it can not implement the print: method.

There is no similar implementation in Java, except that there will be some methods with optional comments in collection, but collection is a special case.

Implementation of the protocol

A class implements some protocols written in the interface definition. Syntax: the protocol name is enclosed by angle brackets, multiple protocol names are separated by commas, and the protocol is written on the right side of the parent class (if there is no parent class, it is written directly on the right side of the child class).


@interface  class MyClass : NSObject <Printable, Drawable>

Printable and drawablew are two protocols.

The corresponding java version is:

public class MyClass extends NSObject implements Printable, Drawable {


Classification can add methods to an existing class without changing its source code. There are no similar features in Java and PHP.

For example, nsobject is an Objective-C built-in system class. We want to add a tojson method to it, like this:

Header file: nsobject + JSON. H

@interface NSObject (Json)

Implementation file: nsobject + JSON. M

@implementation NSObject (Json)
    -(NSString)toJson {

When using, as long as the nsobject + JSON. H is included and the nsobject class is instantiated, the tojson method can be used:

import "NSObject+Json.h"
@implatementation XYZController
    -(void)test {
        NSObject *obj = [[NSObject alloc]init];
        NSString *str = [obj toJson];

Of course, the original methods of nsobject can still be used, nothing has changed, but there are more tojson methods. Does it look like it’s not much different from inheritance (except that nsobject is instantiated instead of jsonobject when it’s used)? Let’s look at another example where inheritance can’t be implemented:

Header file: nsobject + JSON + XML. H

@interface NSObject (Json)

@interface NSObject (XML)

Implementation file: nsobject + JSON + XML. M

@implementation NSObject (Json)
    -(NSString)toJson {

@implementation NSObject (XML)
    -(NSString)toXML {


import "NSObject+Json+XML.h"
@implatementation XYZController
    -(void)test {
        NSObject *obj = [[NSObject alloc]init];
        NSString *json = [obj toJson];
        NSString *xml = [obj toXML];

Cocoa Touch

Cocoa is the development framework of Mac OS app, and cocoa touch is the framework for IOS development. Most of cocoa touch and cocoa touch are the same, but cocoa touch has some unique things of mobile devices, such as touch screen, acceleration sensor, GPS positioning. The features of multi task and multi window in cocoa are not available in cocoa touch (or not exactly the same as cocoa).

Just like learning Java and learning some spring, hibernate, struts (or other similar Java libraries) to start J2EE applications, learning Objective-C also requires learning cocoa touch framework to successfully develop IOS applications.

Delegate: the most common design pattern

Cocoa touch uses a lot of delegate design patterns.

Common controls: buttons, text blocks, pictures, input boxes



Navigation bar



Shortcut: common R


Search text

search for file

New file / directory

It is recommended to add new ones in finder


Simulator and real machine test

Simulator test

Open your project in Xcode. On the right side of the stop button (the black square button on the right of the run button) on the toolbar at the top of Xcode, there is a drop-down menu that displays “toolbarsearch > iPhone 5.0 Simulator” (your application English name > currently selected debugging). Click the drop-down menu and select iPhone 5.0 simulator (here 5.0 refers to IOS version, no IPhone 5 means that if your project is an iPad app, please select iPad 5.0 simulator, and then press the “run” button, Xcode will automatically compile and install the currently edited and developed app on the simulator.

When operating on the simulator, if you encounter a breakpoint set in Xcode during execution, the simulator will pause and switch the currently active window back to Xcode for you to debug.

Add or cancel breakpoints in Xcode, no need to recompile and install the application to take effect.

Switching the device being emulated

The “hardware” menu of the simulator allows you to choose which device you want to simulate, including iPad and iPhone.

  • Retina: for retina screen, iPhone (retina) for iPhone 4, iPhone 4S
  • 4-inch: 4-inch iPhone. The iPhone (retina 4-inch) is iPhone 5

Switch the IOS version of the simulation

In the simulator’s version menu, you can choose which version of IOS you want to simulate. Devices and versions are independent of each other. IPhone 4S can have 5.0, 5.1 and 6.1 IOS versions. Of course, iPhone 5 cannot have 4.3 IOS versions.

Touch screen

Click (left and right keys are not distinguished) the iPhone and iPad screens on the simulator with the mouse, that is, touch the iPhone and iPad screens with the fingers, which can achieve some touch effects, such as:

  • Mouse click equals finger touch
  • Mouse long press is equal to finger long press (for example, you can long press the application icon on the simulator to call up the confirmation box for deleting the application)
  • Drag with mouse hold equals drag with fingers
  • Double clicking and clicking the home key of the emulator are the same as double clicking and clicking the home key of the real machine
Multi fingered gesture

Multi finger gesture is more complex. It can simulate a simple two finger gesture on the white apple notebook. The touch board of the white apple naturally supports multi finger touch, but to locate the area of the simulator and respond to the multi finger gesture, you need to use some additional keys:

  • Press and hold the option key, and then use two fingers to operate the touchpad, which can simulate two fingers dragging and rotating
  • Press and hold option + shift to simulate double finger closing

Input method and keyboard

Input Chinese

The unique input method on the mobile phone (such as Jiugong input method) cannot be simulated. The default IOS soft keyboard of the simulator only has English input. When testing the application, we need to use Chinese. There are two ways:

  • Use the clipboard, copy in Mac OS, press and hold the mouse on the input box of the application running in the simulator for more than 3 seconds, and then select when paste pops up.
  • In the simulator, press home to find the setting app icon (not the simulator menu at the top of Mac OS, where there is no setting), open the settings of the simulated IOS device, and then click “general – Keyboard – International Keyboards – add new keyboard…” , add a Chinese keyboard, and then you can use the software disk of the simulated IOS device to input Chinese, just like on the iPhone / iPad.

Using the MAC keyboard

If you want to input a large amount of text, and the efficiency of using the software keyboard in the simulator is too low, you can use the physical keyboard at this time. The method is: in the simulator menu bar at the top of Mac OS, click the “hardware” menu, and check the “analog hardware keyboard” in the pull-down menu. In the future, when running IOS application with simulator, click the input box in IOS application, the soft keyboard will not pop up, and the physical keyboard of Mac can be directly used for input.

Be careful

  • IOS in the simulator takes over the physical keyboard input, so the input method of IOS in the simulator is called, not that of your Mac. For example, your Mac OS is equipped with Sogou’s five strokes. In the simulator, IOS adds a new keyboard. If you input Chinese in IOS application, the Pinyin input method will be called.
  • To switch between Chinese and English input methods of IOS in the simulator, you can only press the small earth icon on the IOS device’s soft keyboard, but not the command + space bar on the Mac.

geographical position

But the MAC does not have the hardware (GPS) and software foundation for positioning, so the simulator can not automatically obtain the current geographical location, and can not use the simulator to test the positioning function. (note that although WiFi can also be located independently – the iPad WiFi version does not have GPS, but the MAC WiFi does not have location related software)

To test the location dependent function in the simulator (such as “XX near me”), you can manually assign a longitude and latitude to the simulator. Method: on the simulator menu at the top of the Mac computer, click “debug position set position”, a dialog box will pop up, and fill in the longitude and latitude in the pop-up box.

How to get latitude and longitude?
Go to Google map (ditu. Google. CN) and find the location you want on the map (for example, if you want to know the location of Hangzhou building, you can find Hangzhou building through the search box). Right click and select “what is here”. The longitude and latitude of this location will appear in the search box, with latitude in the front and longitude in the back. The territory of our Dynasty is both north latitude and east longitude.


Mac has camera, but Mac OS doesn’t design API to call IOS simulator, so we can’t use simulator to test focusing flash and other functions.

To test the function of relying on photos on the simulator, you can make a workaround in the code, that is, when the code detects that the camera is unavailable, a photo selector will pop up to let the tester select a photo from the album for subsequent operations (such as photo beautification, face recognition, barcode scanning).

Real machine test

Simulators can verify most of the functions of IOS applications you develop, but some MAC devices do not have the hardware, simulators can not be simulated. The previous article mentioned a way to bypass these restrictions, but it is impossible to obtain the current position, take photos and acceleration sensing. Before an application is released to consumers, it must be verified on a real device.

There are three ways to install apps that have not been submitted to the app store for approval on IOS devices for testing:

  • Join Apple’s Developer program and become a paid member. With this paid membership, you can click “run” in Xcode directly to install the newly modified code compilation package to the IOS device for development and test. Operating the tested program on the IOS real machine can activate the breakpoint set in Xcode.
  • Jailbreak IOS device. After jailbreaking the iPhone and iPad, you can directly upload the compiled IPA package of Xcode through SSH (an IOS app is essentially an IPA package).
  • The jailbroken IOS device, with the cracked Xcode, can even achieve the same function as the paid developer plan: click “run” on the Xcode, and then automatically compile and install it to the IOS device to run
  • Enterprise deployment plan. Just like Alibaba’s Xuanyuan sword, you can use iPhone / iPad to visit the website and click the Xuanyuan sword link to install the application.

It’s illegal to crack Xcode (jailbreak is legal), and the version selection is fierce. Not all Xcode versions can crack, and not all Xcode versions can work well with jailbreak IOS. Jailbreak + SSH upload is as inefficient as enterprise deployment (deployment efficiency is low, breakpoints in Xcode cannot be activated). It can only be used for QA acceptance, and is not suitable for development self-test. To sum up, the most suitable way to develop real-time testing is the first formal way. Let’s focus on this:

Have a developer account

Apple’s Developer program is divided into individual developers and company developers, which are $99 per year and $299 per year respectively, and can register 100 and 500 Apple test devices respectively. For example, if the payment is successful on April 1, 2013, the paid membership will be valid before March 31, 2014. During this period, the number of registered units will be less than one quota. Even if the equipment is deleted one minute after it is registered, the reduced quota will not be returned.

Before paying, it’s better to ask the colleagues around you if they have already paid. If yes, you only need to sign up for a free Apple ID (the Apple ID you use to install the software in the app store), ask him to send you an invitation email, and add your Apple ID to his team. Apple will think that you two are a team, and you share the quota of 100 devices with your own account, which is legal.

Install certificate and private key


If you want to log in, you can log in with your Apple ID (if you have paid, or find someone who has paid to join you in the team).
Don’t worry, or want to know how to enter certificate management next time I don’t have this document? Follow this procedure:

  • Enter Apple Developer Center
  • Click IOS Dev Center
  • Click the blue “login” button, log in with your Apple ID, and the successful login will jump to the developer homepage
  • Click the IOS provisioning portal in the upper right corner
  • Click certificates in the menu bar on the left

There is a “your certificate” area on the page, and a download button at the bottom. This is your personal certificate. Download it. In the next line, there is a sentence “if you do not have the wwdr intermediate certificate installed, click here to download now”. This is Apple’s public certificate, too.

Double click the downloaded certificate. When installing the certificate, you will be prompted to enter the password. This is the [key chain access tool] asking you for your Mac OS account power on password (equivalent to sudo in Linux), not the Apple ID password. Don’t get it wrong.

Install private key

If you are an account shared with other colleagues, ask them to give you a private key, that is, a file with the extension of p12. Double click it, and the key chain access will come out automatically. You need to enter a password. This password is not your Mac OS system power on password or your Apple ID password, but asked for by the person who gave you the p12 file.

Registering devices to provisioning portal

  • Open Xcode, find the organizer from Xcode’s window menu, and open it (shift command 2).
  • Connect your IOS device to your computer, and the organizer will automatically recognize your device and display it in the left sidebar.
  • Find your device in the left sidebar of the organizer, right-click it, click “add device to provisioning portal”, and wait for the organizer to prompt you that the operation is successful. (after selecting the device, a button “use for development” will be displayed in the device details area on the right, and you can click it).

Run the beta program on the IOS real machine

Back to the Xcode main interface, on the right side of the stop button (the black square button on the right of the run button), there is a drop-down menu, displaying “toolbarsearch > iPhone 5.0 Simulator” (your application English name > currently selected debugging). Click the drop-down menu, select your real device name, and then press the “run” button, Xcode will automatically open the currently editing The application compiled and installed on the real machine for testing!

Publish to app store

IPA bag

IPA package is essentially a zip compressed package, but it has a special directory structure with the extension IPA. The production method is as follows:

  • Build project in Xcode, shortcut key command B
  • In the left project navigator, expand the products folder, find the application you want to package, your application name. App, right-click, and select Show in finder
  • In finder, copy the. App directory (select, press command C), and copy it to a new folder named payload (case sensitive)
  • Find your application logo, which is a 512 * 512 pixel PNG file, copy it to and with payload (side by side with payload, don’t put it in payload), and rename it to iTunes artwork (case sensitive, no extension)
  • Type the payload directory, iTunes artwork file into a zip package, and change the extension to IPA
  • Double click the IPA file, and it will be opened with iTunes. If it is opened successfully and the application logo is displayed in iTunes, it will be successful

Batch Auto Packaging

In addition to the app store, there are many other IOS application markets (such as 91 assistant, synchronous push, etc.). If an application needs to be published to many application markets, and their codes are slightly different (for example, the statistical codes are different), it is easier to make mistakes by manually modifying the source code and repacking and restoring it according to the above methods. The good news is that Xcode has command lines. We can write a shell script, first use se to automatically modify the source code, then call Xcode’s command line to compile to get the your app.app directory, and finally call zip, MV and other commands to automatically execute the IPA packing action mentioned in the previous chapter.

Read application code

Create a new app from scratch: Hello World


Control size in code

The control size and font size in IOS app refer to the same number of points in the retina device (iPhone 4, 4S, 5; the new pad) and non retina device (iPhone 3GS, iPad, iPad 2), although the resolution of iPhone 4 is twice that of 3GS. For example, 10point is 20 pixel in retina device and 10 pixel in non retina device (iPhone 3G).

When communicating with project members, use point instead of pixel.

Svn operation file with @ symbol

In IOS applications, file names such as [email protected] often appear. They are high-resolution large images for retina devices. When operating them with SVN command line, they will be interfered by @ symbol. The solution is to add an @ symbol at the end of SVN command, such as:

svn del [email protected]@
svn info [email protected]@

If you move dozens of PNG files at a time and then SVN commit, you can use shell batch processing:

svn status | awk '($1=="!"){print $2}' | grep -v @ | xargs svn del

The above command is to delete the file whose name does not contain the @ symbol and is no longer on the hard disk from SVN version control L

for file in `svn status | awk '($1=="!"){print $2}' `; do svn del $file"@"; done     

The above command is to delete the files whose names contain the @ sign and are no longer on the hard disk from SVN version control L

Svn add is the same as above, just like the process

The code structure in Xcode is not consistent with the file system on the operating system

It is recommended to build a directory in finder and then click “add files to” in Xcode’s project navigator to add it to the project

IPhone 5 adaptation

Unlike the previous iPhone, the iPhone 5 uses a 4-inch retina screen, so its number of points becomes 320 * 568 points

open source

  • Apple’s official sample code
  • Open source IOS app on Wikipedia
  • IOS opensource — domain parking, which can be downloaded from twitter and WordPress clients before
  • code 4 app
  • UI 4 app, sister station of code4app

Objective-C tutorial

  • Apple official tutorial
  • Cocoa Dev Center
  • Introduction to Objective-C language on Wiki — Chinese, 10 minutes to read, recommended

Via Bole Online

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: Official address: https://api-mop.chinaums.com/ 2: UnionPay payment Test address: 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 […]