iOS Development UI Foundation Plis file-dictionary to model

Source: Internet
Author: User

What is a plist file?

It is not a reasonable practice to write data directly into the code in development if the data changes frequently, it is often necessary to turn over the corresponding code to make the code less extensible.

Therefore, it is possible to consider placing frequently changing data in a file, and then reading the latest data from the file after the program starts. If you want to change the data, directly modify the data? file, no? Modify code

Can I use a property list? File store data such as Nsarray or nsdictionary, this " attribute list? file " extension is plist, so also known as "plist? File "

Steps to create a plist file in Xcode:

Parsing plist files

Parsing process for plist files

Plist Use Note:

The file name of plist is not called "info" or "info".

Add plist and other file resources when you drag a file into the project, be sure to tick the following options:

Through the above explanations, I believe you already know that we have a dictionary from plist. When we want to get the data, we can use the key in the dictionary to get the value, but use the dictionary is a certain flaw:? In the same case, setting the data and removing the data makes it a "string type of key", when writing these keys, the editor does not have a smart mention, need to hand knock
dict[@ "name"] = @ "Jack"; NSString *name = dict[@ "name"];
    • ? Hand knocking string Key,key easy to write wrong

    • ? If the key is incorrectly written, the compiler will not have any warnings or errors, resulting in incorrect data or incorrect data. The benefits of using the model

    • The so-called model, in fact, is the data model, specifically, the object used to store the data, and use it to table the data will be more professional
    • The model sets the data and takes out the data through its properties, the property name if the error is written, the compiler will immediately error, so that the correctness of the data
    • When you access a property with a model, the compiler provides a series of references, and the high coding efficiency
How do dictionaries go to models? The process of dictionary to model

The operation of the dictionary-to-model is best encapsulated in the model internal model should be provided? A construct that can be passed into a dictionary parameter? Methods the general model will provide such two construction methods Instancetype instancetype in the Type table, the same as the ID, you can show any object type
Instancetype can only be used on return value type, not like ID? used on parameter types
Instancetype? More than an ID? One benefit: The compiler detects the true type of instancetype

Class Prefix
    • When developing iOS programs with OBJECTIVE-C, it is best to add a prefix to each class name, which is used to identify the "home" of the class.
    • ? The purpose is to prevent N. People have developed the same class, conflict
    • ? For example, Jake will, Kate's rooms are all in the same category? Since the development of a button class, such a program is not shipped? line up.
    • Solution: Jake'll 's class name, called Jwbutton,kate, is called Krbutton.
Package for ViewWhat if? A child control inside a view? More often than not? Custom? A view that puts it inside? Child controls are created to shield them from the outside world.The outside world can pass in the corresponding model data to View,view to get the model data to the internal? Child controls set the corresponding databasic steps for encapsulating controlsAdd a child control in the initWithFrame:? method to provide convenient construction? Methodin the Layoutsubviews method, set the child control's frame (do you want to adjust it? with Super Layoutsubviews)Add model properties, set data to the child control in the model properties set? Method

What Xib and storyboard have in common:

    • Used to describe the software interface?

    • With interface Builder? Tools to edit
    • The essence is to convert the code to create the control
Different points:
    • Xib is lightweight, and is used to describe a local UI interface?
    • Storyboard is a heavyweight, and is used to describe the entire software across multiple boundaries, and to show the jump relationship between multiple boundary polygons
Two ways to load Xib:

To make use of xib? To customize a view
    • To create a new custom control class

    • New Xib file (file name minus one and the class name of view are the same)

    • Modify the class name of view in Xib

    • Loading process for encapsulated Xib

    • Add model properties set data to child controls in the model properties set method
Note the point:There are 2 ways to create a control.
-When initializing? Use initWithFrame:? method

Create with Xib\storyboard
-Does not adjust when initializing? Use initWithFrame:? method, only adjust the use of Initwithcoder:? Method-After initialization is complete, will be adjusted to use the awakefromnib? method

Sometimes you want to do it when the control is initialized? Some initialization operations, such as adding child controls, setting basic properties

You need to choose which of the initWithFrame:, Initwithcoder:, and awakefromnib, depending on how the control is created? Method operation

UIImage Brief Introduction

A UIImage object represents a picture in general by imagenamed: method to load a picture in a project by file name

Such as:

Basic settings for Uilabel

Uifont represents a common way to create fonts with the following several

Selection characteristics of UIButton, Uiimageview and UilabelUIButton
-Can not only display the text, but also show the picture of the film (can be shown in 2 pictures, background map, film, content map)-long press, you can switch the picture when highlighting ?
-Directly through addtarget ...? Method Monitor Click

Uiimageview
-Can show the picture, not directly through the addtarget ...? Method Monitor Click

UILabel
-able to display the text, not directly through the addtarget ...? Method Monitor Click

Choose

Just show the data, do not need to click on the recommended choice Uiimageview, UILabel

Not only show the data, but also listen to the click
Recommended Choice UIButton actually Uiimageview, Uilabel can also through? gesture recognizer to listen (after-face course will learn)

When you press and hold the control, the contents of the display are changed. Consider, choose UIButton (because UIButton has highlighted this state)

At the same time, show 2 pictures of the film: Background map, film, content map? With consideration, choose UIButton

Common Xcode Plugin recommendations: http://www.cocoachina.com/industry/20130918/7022.html

How to get app internal resources
    • Install a itools Baidu is a bit
    • Connect the device with USB to open itools
    • Then select an app

Additional knowledge:
# # timed Tasks-Method 1:performselector//automatically call Self's Hidehud method after 1.5s[Self performselector: @selector (Hidehud) Withobject:nil Afterdelay:1.5];-Method 2:gcddispatch_after (Dispatch_time (Dispatch_time_now, (int64_t) (1.5* nsec_per_sec)), Dispatch_get_main_queue (), ^{    //The code inside the block is automatically executed after 1.5sSelf.hud.alpha =0.0;});-Method 3:nstimer//automatically call Self's Hidehud method after 1.5s[Nstimer Scheduledtimerwithtimeinterval:1.5target:self selector: @selector (Hidehud) Userinfo:nil Repeats:no];//repeats if yes, means that the self's Hidhud method is called every 1.5s
Hud
    • -Other sayings: indicator, cover, mask
    • -Translucent HUD Approach
    • -Background color set to translucent color
Problems

-An. m file inside the project is not available
-Check: Build phases-Compile Sources
-A resource file within the project (such as plist, audio, etc.) cannot be used
-Check: Build phases Copy Bundle Resources

Model what is a model?
    • -objects that are designed to hold data
    • -Generally are pure objects that inherit directly from NSObject
    • -some properties are provided internally to hold the data
What is the possibility that a control cannot be seen?
    • -the width or height is actually 0.
    • -Incorrect position (for example, a negative number or an oversized count that has exceeded the screen)
    • -Hidden = = YES
    • -Alpha <= 0.01
    • -No background color set, no content set
    • -may be text and background color
Nine Gongge calculation ideas
    • - calculates the row and column number of the control with the index of the control
    • -Calculates the X value of the control using the column number
    • -Calculates the Y value of the control using the line number

This article has been shared here thanks for your reading!

iOS Development UI Foundation Plis file-dictionary to model

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.