Skip to content

Instantly share code, notes, and snippets.

View JunyiXie's full-sized avatar
:octocat:
Focusing

xiejunyi JunyiXie

:octocat:
Focusing
View GitHub Profile
@JunyiXie
JunyiXie / gist:08f3fd1d19d638e16c440d51f9c424a7
Created May 6, 2018 14:05 — forked from snikch/gist:3661188
Find the current top view controller for your iOS application
- (UIViewController *)topViewController{
return [self topViewController:[UIApplication sharedApplication].keyWindow.rootViewController];
}
- (UIViewController *)topViewController:(UIViewController *)rootViewController
{
if (rootViewController.presentedViewController == nil) {
return rootViewController;
}
@JunyiXie
JunyiXie / gist:43619fcd3d31cc9e235211f5cc0c7736
Created May 6, 2018 06:43 — forked from chrisballinger/gist:3352890
Fuzzy string match objective-c (Levenshtein Distance Algorithm)
-(float)compareString:(NSString *)originalString withString:(NSString *)comparisonString
{
// Normalize strings
[originalString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
[comparisonString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
originalString = [originalString lowercaseString];
comparisonString = [comparisonString lowercaseString];
// Step 1 (Steps follow description at http://www.merriampark.com/ld.htm)