Skip to content

GabrielMassana/SearchEmojiOnString-iOS

Repository files navigation

SearchEmojiOnString-iOS

Version License Platform CocoaPods Build Status

What is it?

Category to search emojis on an NSString.

Category to search emojis on an NSString. The category allows to check if has emojis, the number of emoji, the range of the emojis and if the string consists entirely of 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.

About

Category to search emojis on an NSString. The category allows to check if has emojis, the number of emoji, the range of the emojis and if the string consists entirely of emojis.

Resources

License

Stars

Watchers

Forks

Packages

No packages published