Simple iOS demo with Chinese Dictionary or dictionary

Source: Internet
Author: User

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

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.