Created
August 8, 2013 16:17
-
-
Save zhangxigithub/6186089 to your computer and use it in GitHub Desktop.
iOS所有的类
This file contains hidden or 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
| NSMutableDictionary *result = [NSMutableDictionary dictionary]; | |
| NSFileManager *manager = [NSFileManager defaultManager]; | |
| NSString *root = @"/Users/zhangxi_imac/Desktop/未命名文件夹 2/Frameworks"; | |
| NSArray *dirs = [manager contentsOfDirectoryAtPath:root error:nil]; | |
| for(NSString *dir in dirs) | |
| { | |
| NSLog(@"%@",dir); | |
| NSMutableDictionary *classes = [NSMutableDictionary dictionary]; | |
| NSString *path = [[root stringByAppendingPathComponent:dir] stringByAppendingPathComponent:@"Headers"]; | |
| // NSLog(@"%@",[manager contentsOfDirectoryAtPath:path error:nil]); | |
| for(NSString *file in [manager contentsOfDirectoryAtPath:path error:nil]) | |
| { | |
| NSString *filePath = [path stringByAppendingPathComponent:file]; | |
| NSString *content = [[NSString alloc] initWithContentsOfFile:filePath | |
| encoding:NSUTF8StringEncoding | |
| error:nil]; | |
| NSRange range = [content rangeOfString:@"@interface"]; | |
| if(range.length != NSNotFound) | |
| { | |
| NSString *searchString = content; | |
| //NSString *regexString = @"(?<=@interface).*(?=\\s(?:<|\\s))"; | |
| NSString *regexString = @"(?<=@interface).*(?=[{\\n])"; | |
| //@"@interface.*[{\\n]"; | |
| NSArray *matchArray = [searchString componentsMatchedByRegex:regexString]; | |
| NSLog(@"matchArray: %@", matchArray); | |
| for(NSString *theClass in matchArray) | |
| { | |
| NSString *name = [theClass stringByReplacingOccurrencesOfString:@" " withString:@""]; | |
| NSArray *array = [name componentsSeparatedByString:@":"]; | |
| if(array.count == 2) | |
| { | |
| NSString *parentName = array[1]; | |
| parentName = [parentName stringByReplacingOccurrencesOfString:@"{" withString:@""]; | |
| NSRange p = [parentName rangeOfString:@"<"]; | |
| if(p.location != NSNotFound ) | |
| parentName = [parentName substringToIndex:p.location]; | |
| [classes setObject:parentName forKey:array[0]]; | |
| } | |
| } | |
| }else | |
| { | |
| // NSLog(@"没有类 %@",file); | |
| } | |
| } | |
| [result setObject:classes forKey:dir]; | |
| } | |
| NSLog(@"%@",result); | |
| [result writeToFile:@"/Users/zhangxi_imac/Desktop/ccccc.plist" atomically:YES]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment