HNKWordLookup 1.1.5

HNKWordLookup 1.1.5

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Apr 2015

Maintained by Harlan Kellaway.


Downloads

Total299
Week2
Month4

Installs

Apps11
Apps WeekApps This Week 1
Test Targets1
powered by Segment

GitHub

Stars20
Watchers2
Forks3
Issues0
Contributors2
Pull Requests0

Code

Files13
LOCLines of Code 669


 
Depends on:
AFNetworking~> 2.5
Mantle~> 1.5
 

  • By
  • Harlan Kellaway

HNKWordLookup is a Cocoapod that performs standard English-language dictionary queries, such as definitions, pronunciations, random words, and Word of the Day.

Communication

Getting Started

Podfile

platform :ios, '7.0'
pod "HNKWordLookup", "~> 1.1"

API Key

HNKWordLookup uses the Wordnik API to lookup information. You will need a Wordnik API key in order to use HNKWordLookup.

  • Create a Wordnik account
  • Once activated, find your API key on your Settings page

Classes

  • HNKLookup
  • HNKWordDefinition
  • HNKWordPronunciation
  • HNKWordOfTheDay

Usage

Setup

Requests cannot be made without first supplying HNKLookup with your Wordnik API Key (see Getting Started). Once your API key is obtained, you can setup HNKLookup for use by calling sharedInstanceWithAPIKey (typically within the AppDelegate):

[HNKLookup sharedInstanceWithAPIKey:@"YOUR_API_KEY"];

You should replace YOUR_API_KEY with your Wordnik API key.

Lookups

HNKLookup is responsible for handling any lookups of information. Once Setup is complete, lookup requests can be made to [HNKLookup sharedInstance].

Looking up definitions

[[HNKLookup sharedInstance] definitionsForWord:@"center" completion:^(NSArray *definitions, NSError *error) {
    if (error) {
        NSLog(@"ERROR: %@", error);
    } else {
        for (HNKWordDefinition *definition in definitions) {
            NSLog(@"%@", definition);
        }
    }
}];

Looking up definitions with specific partsOfSpeech

Note: The partsOfSpeech argument can take any number of HNKWordDefinitionPartOfSpeech types separated by a | symbol.

[[HNKLookup sharedInstance] definitionsForWord:@"center" 
                                 withPartsOfSpeech:HNKWordDefinitionPartOfSpeechNoun | HNKWordDefinitionPartOfSpeechVerbTransitive
                                        completion:^(NSArray *definitions, NSError *error) {
    if (error) {
        NSLog(@"ERROR: %@", error);
    } else {
        for (HNKWordDefinition *definition in definitions) {
            NSLog(@"%@", definition);
        }
    }
}];

Looking up pronunciations

[[HNKLookup sharedInstance] pronunciationsForWord:@"orange" completion:^(NSArray *pronunciations, NSError *error) {
    if (error) {
        NSLog(@"ERROR: %@", error);
    } else {
        for (HNKWordPronunciation *pronunciation in pronunciations) {
            NSLog(@"%@", pronunciation);
        }
    }
}];

Looking up a random word

[[HNKLookup sharedInstance] randomWordWithCompletion:^(NSString *randomWord, NSError *error) {
    if (error) {
        NSLog(@"ERROR: %@", error);
    } else {
        NSLog(@"%@", randomWord);
    }
}];

Looking up the wordOfTheDay

[[HNKLookup sharedInstance] wordOfTheDayWithCompletion:^(HNKWordOfTheDay *wordOfTheDay, NSError *error) {
    if (error) {
        NSLog(@"ERROR: %@", error);
    } else {
        NSLog(@"%@", wordOfTheDay);
    }
}];

Looking up the wordOfTheDay for a specific date

[[HNKLookup sharedInstance] wordOfTheDayForDate:[NSDate date] completion:^(HNKWordOfTheDay *wordOfTheDay, NSError *error) {
    if (error) {
        NSLog(@"ERROR: %@", error);
    } else {
        NSLog(@"%@", wordOfTheDay);
    }
}];

Delegate Methods

Delegate methods are available to classes that implement the HNKLookupDelegate protocol.

Optional Delegate Methods

(BOOL)shouldDisplayNetworkActivityIndicator

The return value of this method determines whether the activity indicator in the status bar is displayed while HNKLookup makes network requests. The default is NO.

To have the activity indicator displayed, the class that implements the HNKLookupDelegate protocol should include the following method call:

- (BOOL)shouldDisplayNetworkActivityIndicator {
  return YES;
}

Credits

HNKWordLookup was created by Harlan Kellaway and uses the Wordnik API.

License

HNKWordLookup is available under the MIT license. See the LICENSE file for more info.