Advertisement
Guest User

Untitled

a guest
Nov 17th, 2017
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //подключить этот инклюд
  2.   #include <objc/runtime.h>
  3.  
  4.  
  5.  
  6. //вставить этот код
  7.     Class LSApplicationWorkspace_class = objc_getClass("LSApplicationWorkspace");
  8.     NSObject* workspace = [LSApplicationWorkspace_class performSelector:NSSelectorFromString(@"defaultWorkspace")];
  9.     NSArray* appProxies = [workspace performSelector:NSSelectorFromString(@"allApplications")];
  10.    
  11.     Ivar bundleUrlIvar = class_getInstanceVariable([appProxies.firstObject class], "_bundleURL");
  12.    
  13.     NSMutableString* result = [NSMutableString string];
  14.     for (id appProxy in appProxies)
  15.     {
  16.         NSURL* url = object_getIvar(appProxy, bundleUrlIvar);
  17.         // at this point you have the information and you can do whatever you want with it
  18.         // I will make it a list as you asked
  19.         if (url)
  20.         {
  21.             [result appendFormat:@",%@", [url lastPathComponent]];
  22.         }
  23.     }
  24.    
  25.     if (result.length > 0)
  26.     {
  27.         // remove comma from beginning of the list
  28.         [result deleteCharactersInRange:NSMakeRange(0, 1)];
  29.     }
  30.    
  31.    
  32.     NSLog(@"apps: %@", result);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement