Skip to content

Instantly share code, notes, and snippets.

@ichitaso
Created December 19, 2021 14:49
Show Gist options
  • Save ichitaso/39d17c47d97adafd9abc58d67b1b4c77 to your computer and use it in GitHub Desktop.
Save ichitaso/39d17c47d97adafd9abc58d67b1b4c77 to your computer and use it in GitHub Desktop.
NSArrayのarrayをNSRangeのrangeOfString:を使わないで複数フィルタリング(簡易)
#define PREF_PATH @"/private/var/mobile/Library/Preferences"
void filterPath() {
NSFileManager *fileManager = [[NSFileManager alloc] init];
NSArray *allFileName = [fileManager contentsOfDirectoryAtPath:PREF_PATH error:nil];
NSArray *filterFile = @[@".GlobalPreferences.plist",
@"TVRemoteConnectionService.plist",
@"UITextInputContextIdentifiers.plist",
@"nfcd.plist",
@"com.google.gmp.measurement.plist",
@"com.google.gmp.measurement.monitor.plist"];
NSMutableArray *hitFileNames = [NSMutableArray array];
for (NSString *fileName in allFileName) {
NSRange range = [fileName rangeOfString:@"com.apple."];
if (range.location == NSNotFound && ![filterFile containsObject:fileName]) { // <- ここ
NSString *fileNamePath = [NSString stringWithFormat:@"%@/%@",PREF_PATH, fileName];
[hitFileNames addObject:fileNamePath];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment