ios--Summary Series Three

Source: Internet
Author: User

the advantages of replacing dictionaries with models• Disadvantages of using dictionaries ø in general, setting data and fetching data use "String type Key", when writing these keys, the compiler will not have any friendly prompts, need to knock

dict[@ "name"] = @ "Jack";

NSString *name = dict[@ "name"];

Ø Hand knocking string Key,key easy to write wrong Økey if written incorrectly, the compiler will not have any warnings and errors, resulting in incorrect data or wrong data • Use the benefits of the model o the so-called model, is actually the data model, specifically used to store data objects, use it to represent the data will be more professional O 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 using the model access properties, the compiler will provide a series of hints to improve the efficiency of coding

App.name = @ "Jack";

NSString *name = App.name

second, dictionary to model• The process of dictionary-to-model is best encapsulated inside the model • The model should provide a construction method that can pass in the dictionary parameters ø-(instancetype) initwithdict: (Nsdictionary *) dict; ø+ (Instancetype) xxxwithdict: (Nsdictionary *) dict;Third, Instancetypeinstancetype on a type representation, as with an ID, you can represent any object type Instancetype can only be used on the return value type and not on the parameter type as an ID · One benefit of instancetype than ID: The compiler detects the true type of instancetypeiv. use of xib filesThe xib file can be used to describe a piece of local UI interface xib File loading O Method 1

Nsarray *OBJS = [[NSBundle mainbundle] loadnibnamed:@ "Mjappview" Owner:nil Options:nil];

This method creates all the objects in the Xib and places the objects in the OBJS array in order

(if Xib is shown in the image on the right, then there are 3 objects in the OBJS array: 1 UIView, 1 UIButton, 1 uiswitch)

Ø Method 2

The bundle parameter can be nil, the default is the main bundle

uinib *nib = [uinib nibwithnibname:@ "Mjappview" Bundle:[nsbundle Mainbundle]];

Nsarray *OBJS = [nib Instantiatewithowner:nil options:nil];

• In the development phase, the Xib file is for developers; When the app is loaded on the phone, the Xib file is converted to a nib filev. Comparison of xib and storyboard• Common points: Ø are used to describe the software interface Ø are edited using the Interface Builder tool • The øxib is lightweight, describing the local UI Østoryboard is heavyweight, used to describe the entire software's multiple interfaces, And can show the jump relationship between multiple interfacesVi. Package of view• If you have more than one child control inside a view, you will typically consider customizing a view to shield the creation of its inner child controls from external concerns • The outside world can pass in the corresponding model data to the View,view to get the model data and set the corresponding data to the inner child controls.Vii. Summary

1.Xcode path from the lead file

/applications/xcode.app/contents/developer/platforms/iphonesimulator.platform/developer/sdks/ Iphonesimulator7.1.sdk/system/library/frameworks/uikit.framework/headers

2. After modifying the system self-lead file, Xcode will error

Solution: Delete the cache of the following folder (Aplle is the user name of the computer)

/users/aplle/Resource Library/developer/xcode/deriveddata

Or

/users/aplle/library/developer/xcode/deriveddata

3. To encapsulate a custom view using Xib

1> Create a custom view that inherits UIView, assuming the class name is called (Mjappview)

2> Create a new Mjappview.xib file to describe the structure inside the Mjappview

3> Modifying the type of UIView is Mjappview true Type

4> the inner child control with the Mjappview property connection

5> Mjappview provides a model property

6> overrides the set method of the Model property, because the model data passed in the set method can be obtained

7> The model data, setting the data to the corresponding sub-controls separately

8> Add: Provides a class method to create a mjappview that masks the code that reads the Xib file.

ios--Summary Series Three

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.