A. Dictionary to model (this method is used later)
//defined in Model.h
-(Instancetype) Initwithdictionary: (Nsdictionary *) Dict;
//In MODEL.M -(Instancetype) Initwithdictionary: (Nsdictionary *) dict{if(self =[Super Init]) {[Self setvaluesforkeyswithdictionary:dict]; } returnSelf ;}
//Setvalue:forundefinedkey: A must-write method in model.m -(void) SetValue: (ID) value Forundefinedkey: (NSString *) key{ // if ([Key isequaltostring:@ "id"]) {//Self.movieid = value; // }}
//Call Newsmodel*model = [[Newsmodel alloc] initwithdictionary:dict];
Two. Use of WebView
<UIWebViewDelegate>@property (nonatomic, strong) UIWebView*WebView, @property (nonatomic, strong) Uiactivityindicatorview*Activityindicator;//Initialize UIWebView_webview =[[UIWebView alloc] initWithFrame:self.view.frame]; Nsurlrequest*request = [Nsurlrequest requestwithurl:[nsurl urlwithstring:@"http://baidu.com"]]; [Self.view Addsubview:_webview]; [_webview loadrequest:request];//UIWebView has 3 agent methodologies to follow the Uiwebviewdelegate protocolSelf.webview.Delegate=Self ;#pragma-mark webviewdelegate//determine whether to load before loading-(BOOL) WebView: (UIWebView *) WebView shouldstartloadwithrequest: (Nsurlrequest *Request Navigationtype: (uiwebviewnavigationtype) navigationtype{returnYES;}- (void) Webviewdidstartload: (UIWebView *) webview{NSLog (@"Web page starts loading");//a daisy appears on the load waiting page//creating a back-end translucent viewUIView *view =[[UIView alloc] initWithFrame:self.view.frame]; View.tag=108; View.backgroundcolor=[Uicolor Blackcolor]; View.alpha=0.5; [Self.view Addsubview:view];//Initialize UiactivityindicatorviewSelf.activityindicator = [[Uiactivityindicatorview alloc] Initwithframe:cgrectmake (0,0,0,0)]; [View AddSubview:self.activityIndicator]; Self.activityIndicator.center=View.center;//set the style of UiactivityindicatorviewSelf.activityIndicator.activityIndicatorViewStyle =Uiactivityindicatorviewstylewhitelarge;//Start Display[Self.activityindicator startanimating];}- (void) Webviewdidfinishload: (UIWebView *) webview{NSLog (@"Web page loading complete");//Find and remove a view by tag valueUIView *view = [Self.view viewwithtag:108]; [View Removefromsuperview];}- (void) WebView: (UIWebView *) WebView didfailloadwitherror: (Nserror *) error{NSLog (@"page loading error, error:%@", error); UIView*view = [Self.view viewwithtag:108]; [View Removefromsuperview];}
Knowledge Supplement One. Dictionary to model, use of WebView