First of all, thank the withered RyuGin NetEase Blog to provide "idiom dictionary" "Xinhua Dictionary" "Chinese Dictionary" interface for use.
Inadvertently found on the Internet a Chinese dictionary interface, so I tested it, found that can be used, thank the great God!!!
Attached Demo:
Mainly used in the way of data parsing, the server is returning JSON data, directly using the classes provided by iOS to parse, this small demo is very simple, directly attached to the source code: (I encapsulated a method, the address of the incoming server and the requested data, back to the main thread update UI)
1 //2 //VIEWCONTROLLER.M3 //Xinhua Dictionary4 //5 //Created by Hukezhu on 15/7/7.6 //Copyright (c) 2015 Hukezhu. All rights reserved.7 //8 9 #import "ViewController.h"Ten #import<AFNetworking.h> One A @interfaceViewcontroller () -@property (Weak, nonatomic) Iboutlet Uitextfield *Word; -@property (Weak, nonatomic) Iboutlet Uitextfield *Chengyu; the@property (Weak, nonatomic) iboutlet Uitextview *TextView; -@property (Weak, nonatomic) Iboutlet Uitextfield *Ciyu; - --(Ibaction) Wordclick: (UIButton *) sender; +-(Ibaction) Chengyuclick: (UIButton *) sender; --(Ibaction) Ciyuclick: (UIButton *) sender; + A @end at - @implementationViewcontroller - - - - in- (void) Viewdidload { - [Super Viewdidload]; to + } - the *- (void) Getdictionary:(NSString *) strURL Word: (NSString *) word{ $ Panax NotoginsengNSString *stringurl =strURL; -Afhttprequestoperationmanager *manager =[Afhttprequestoperationmanager manager]; theManager.responseSerializer.acceptableContentTypes =[nsset setwithobjects:@"Application/json",@"Text/json",@"Text/javascript",@"text/html", nil]; + A[Manager Get:stringurl parameters:@{@"Word": Word} success:^ (Afhttprequestoperation *operation,IDJSON) { the +NSData *data = [nsjsonserialization Datawithjsonobject:json options:0Error:null]; - $ $Nsdictionary *dict = [nsjsonserialization jsonobjectwithdata:data options:0Error:null]; - - the -NSString *rootkey =Dict.keyEnumerator.nextObject;WuyiNsarray *array =Dict[rootkey]; the - Wu -nsmutablestring *STRINGM = [nsmutablestringstring]; About for(Nsdictionary *dict1inchArray) { $ - for(NSString *keyinchDict1) { - if([Key isequaltostring:@"text"]) { -NSString *Object=[Dict1 Objectforkey:key]; A //NSLog (@ "%@", object); +[Stringm AppendFormat:@"%@\n",Object]; the } - $ } the } the theSelf.textView.text =STRINGM; the} failure:^ (Afhttprequestoperation *operation, Nserror *error) { -NSLog (@"error:%@", error); in }]; the the About } the the-(Ibaction) Wordclick: (UIButton *) Sender { the + //NSLog (@ "Click on the Find button"); - if(self.word.text) { the[Self getdictionary:@"http://brisk.eu.org/api/xhzd.php"Word:self.word.text];Bayi } the the [Self.view Endediting:yes]; - - the } the the-(Ibaction) Chengyuclick: (UIButton *) Sender { the - if(self.chengyu.text) { the[Self getdictionary:@"http://brisk.eu.org/api/cycd.php"Word:self.chengyu.text]; the } the 94 [Self.view Endediting:yes]; the } the the-(Ibaction) Ciyuclick: (UIButton *) Sender {98 About if(self.ciyu.text) { -[Self getdictionary:@"http://brisk.eu.org/api/hycd.php"Word:self.ciyu.text];101 }102 103 104 //This is the dream of Zhou Gong, but the API can not be used the //if (self.ciyu.text) {106 //[self getdictionary:@]http://brisk.eu.org/api/dream.php[Word:self.ciyu.text];107 // }108 109 [Self.view Endediting:yes]; the }111 @end
Simple iOS demo with Chinese Dictionary or dictionary