SearchEmojiOnString 1.1.0

SearchEmojiOnString 1.1.0

TestsTested βœ“
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Mar 2016

Maintained by Gabriel Massana.



  • By
  • Gabriel Massana

SearchEmojiOnString-iOS

What is it?

Category to search emojis on an NSString.

The category allows to check if has emojis, the number of emojis and the range of the emojis.

Installation

Podfile

platform :ios, '8.0'
pod 'SearchEmojiOnString', '~> 1.0'

Then, run the following command:

$ pod install

Old school

Drag into your project the folder /SearchEmojiOnString-iOS. That's all.

Example

ContainsEmoji

YES if the String contains emojis, NO otherwise.

#import "NSString+EMOEmoji.h"

...

    NSString *emojis = @"πŸ€πŸ€‘πŸ€’πŸ€“πŸ€”πŸ€•πŸ€–πŸ€—πŸ€˜πŸ¦€πŸ¦πŸ¦‚πŸ¦ƒπŸ¦„πŸ§€β˜‚οΈβœοΈβœ‘οΈβ˜―οΈ";
    BOOL containsEmoji = [emojis emo_containsEmoji];
    NSLog(@"%@", @(containsEmoji));

    // Output: ["true"]

EmojiCount

Calculate number of emojis on the string.

#import "NSString+EMOEmoji.h"

...

    NSString *emojis = @"πŸ€πŸ€‘πŸ€’πŸ€“πŸ€”";
    NSInteger emojiCount = [emojis emo_emojiCount];
    NSLog(@"%@", @(emojiCount));

    // Output: ["5"]

EmojiRanges

Calculate the NSRange for every emoji on the string.

#import "NSString+EMOEmoji.h"

...

    NSString *emojis = @"🀐emojiπŸ€‘testπŸ€’";
    NSArray *emojiRanges = [emojis emo_emojiRanges];
    NSLog(@"%@", emojiRanges);

    // Output: ["(
    //       "NSRange: {0, 2}",
    //       "NSRange: {7, 2}",
    //       "NSRange: {13, 2}"
    //       )"]

IsPureEmojiString

Thanks to Jichao Wu

Calculate if the string consists entirely of emojis.

#import "NSString+EMOEmoji.h"

...
    NSString *emojisText = @"🀐emojiπŸ€‘testπŸ€’";
    BOOL emojiText_isPureEmojiString = [emojisText emo_isPureEmojiString];
    NSLog(@"%@", @(emojiText_isPureEmojiString));

    // Output: ["false"]

    NSString *emojis = @"πŸ€πŸ€‘πŸ€’";
    BOOL emoji_isPureEmojiString = [emojis emo_isPureEmojiString];
    NSLog(@"%@", @(emoji_isPureEmojiString));

    // Output: ["true"]

License

SearchEmojiOnString-iOS is released under the MIT license. Please see the file called LICENSE.

Versions

$ git tag -a 1.0.0 -m 'Version 1.0.0'

$ git push --tags

Author

Gabriel Massana

Found an issue?

Please open a new Issue here if you run into a problem specific to SearchEmojiOnString-iOS, have a feature request, or want to share a comment.