This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
var numbers = [7, 7, 7, 1, 1, 1, 2, 3, 4, 4, 5, 5, 6, 7, 7, 8, 8] | |
var filter = [Int]() | |
for number in numbers { | |
if !contains(filter, number) { | |
filter.append(number) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)openThisURL:(NSString *)launchUrl withFallback:(NSString *)fallback | |
{ | |
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:launchUrl]]) { | |
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:launchUrl]]; | |
} else { | |
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:fallback]]; | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSString *)mostCommonCharacter:(NSString *)string | |
{ | |
__block NSMutableArray *charIndex = [[NSMutableArray alloc] init]; | |
// Enumerate | |
[string enumerateSubstringsInRange:NSMakeRange(0, string.length) options:NSStringEnumerationByComposedCharacterSequences usingBlock:^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop) | |
{ | |
[charIndex addObject:substring]; | |
}]; | |
NewerOlder