TestsTested | β |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Mar 2016 |
Maintained by Gabriel Massana.
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.
platform :ios, '8.0'
pod 'SearchEmojiOnString', '~> 1.0'
Then, run the following command:
$ pod install
Drag into your project the folder /SearchEmojiOnString-iOS
. That's all.
YES if the String contains emojis, NO otherwise.
#import "NSString+EMOEmoji.h"
...
NSString *emojis = @"π€π€π€π€π€π€π€π€π€π¦π¦π¦π¦π¦π§βοΈβοΈβ‘οΈβ―οΈ";
BOOL containsEmoji = [emojis emo_containsEmoji];
NSLog(@"%@", @(containsEmoji));
// Output: ["true"]
Calculate number of emojis on the string.
#import "NSString+EMOEmoji.h"
...
NSString *emojis = @"π€π€π€π€π€";
NSInteger emojiCount = [emojis emo_emojiCount];
NSLog(@"%@", @(emojiCount));
// Output: ["5"]
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}"
// )"]
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"]
SearchEmojiOnString-iOS is released under the MIT license. Please see the file called LICENSE.
$ git tag -a 1.0.0 -m 'Version 1.0.0'
$ git push --tags
Gabriel Massana
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.