Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //подключить этот инклюд
- #include <objc/runtime.h>
- //вставить этот код
- Class LSApplicationWorkspace_class = objc_getClass("LSApplicationWorkspace");
- NSObject* workspace = [LSApplicationWorkspace_class performSelector:NSSelectorFromString(@"defaultWorkspace")];
- NSArray* appProxies = [workspace performSelector:NSSelectorFromString(@"allApplications")];
- Ivar bundleUrlIvar = class_getInstanceVariable([appProxies.firstObject class], "_bundleURL");
- NSMutableString* result = [NSMutableString string];
- for (id appProxy in appProxies)
- {
- NSURL* url = object_getIvar(appProxy, bundleUrlIvar);
- // at this point you have the information and you can do whatever you want with it
- // I will make it a list as you asked
- if (url)
- {
- [result appendFormat:@",%@", [url lastPathComponent]];
- }
- }
- if (result.length > 0)
- {
- // remove comma from beginning of the list
- [result deleteCharactersInRange:NSMakeRange(0, 1)];
- }
- NSLog(@"apps: %@", result);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement