iOS Development Project-25 dictionary to model Introduction to third-party frameworks and runtime mechanisms

Source: Internet
Author: User

iOS Development Project-25 dictionary to model Introduction to third-party frameworks and runtime mechanisms

First, using a third-party framework to complete the dictionary to model

1. Get the framework

In the www.code4app.com Web site, search the dictionary to model

You can download it by clicking the download code, or you can take github to download it.

Benefits of the Management framework: Clicking the Refresh button refreshes all items.

2. Use

1. Import a third-party framework

2. Using the example

Error message:

Use a single line of code when you refresh:

1 /** Load up-to- date Weibo data*/2-(void) Loadnewstatus3 {4     //1. Obtaining the Request Manager5Afhttprequestoperationmanager *mgr =[Afhttprequestoperationmanager manager];6     7     //2. Package Request Parameters8     9Nsmutabledictionary *params=[Nsmutabledictionary dictionary];Ten     params[@"Access_token"] =[Yyaccounttool Accountmodel].access_token; One     //set Request returns 3 days of data A     params[@"Count"][email protected] A; -   -      the     //3. Send a POST request -    //URL:Https://api.weibo.com/2/statuses/home_timeline.json -[Mgr GET:@"Https://api.weibo.com/2/statuses/home_timeline.json"Parametersparamssuccess:^ (afhttprequestoperation *operation, nsdictionary*accountdict) { -  +Yylog (@"Request succeeded--%@", accountdict[@"statuses"]); - //self.statuses=accountdict[@ "statuses"]; +          ASelf.statuses =[Nsmutablearray array]; at          -         //Weibo dictionary--arrays -Nsarray *statusdictarray = accountdict[@"statuses"]; -          -         //Weibo Dictionary Array---"Weibo model array -self.statuses=[Yystatusmodel Objectarraywithkeyvaluesarray:statusdictarray]; in          - //For (nsdictionary *statusdict in Statusdictarray) { to //Yystatusmodel *status = [Yystatusmodel objectwithkeyvalues:statusdict]; + //[self.statuses addobject:status]; - //        } the // *          $         //re-refresh the tablePanax Notoginseng [Self.tableview Reloaddata]; -} failure:^ (Afhttprequestoperation *operation, Nserror *error) { theYylog (@"request failed"); +     }]; A      the}

Tells the array that the model is stored:

1 //2 //YYSTATUSMODEL.M3 //4 5 #import "YYStatusModel.h"6 #import "MJExtension.h"7 #import "YYPhotoModel.h"8 9 @implementationYystatusmodelTen //+ (Instancetype) statusmodelwithdict: (Nsdictionary *) Dict One //{ A //Yystatusmodel *model=[[self Alloc]init]; - //model.text=dict[@ "text"]; - //     the //model.user=[yyusermodel usermodelwithdict:dict[@ "user"]; - //     - //    //Nested Models - //nsdictionary *retweeteddict = dict[@ "Retweeteddict"]; + //if (retweeteddict) { - //Model.retweeted_status=[yystatusmodel statusmodelwithdict:retweeteddict]; + //    } A //return model; at //} -  --(Nsdictionary *) Objectclassinarray - { -       return@{@"Pic_urls": [Yyphotomodelclass]}; - } in  - @end

Effect:

Ii. introduction of the operation

Runtime: Actually is the bottom of OC, usually write the OC code, eventually converted to the bottom of the runtime code (pure C language)

View the generated files

The converted main function:

Remove the code after the cast:

Note : Understanding the message mechanism

The compiler converts all of the OC code we write into runtime code, and the code above translates to sending messages

OC is a C language that wears an object-oriented cloak.

The runtime emphasizes the ability to dynamically modify, delete methods, and so on.

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.