Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Accessing obj-c help
-
So I'm trying to access the functionality of an objective-c class,
The objective-c code i'm trying to replicate is:
NSArray *apps = [[LSApplicationWorkspace defaultWorkspace] allInstalledApplications];
currently I can do this:
appWorkspace = ObjCClass('LSApplicationWorkspace') default = (appWorkspace.defaultWorkspace)
But I can't find a way to access the 'allInstalledApplications' method.. any ideas?
-
Your
defaultWorkspace
call is missing parentheses. It should beappWorkspace.defaultWorkspace()
. -
Can't believe i missed that! Thank you!
Great app btw, very impressive indeed
-
I'm curious. In which way I have to use NSArray?
apps = list(default.allInstalledApplications()) for app in apps: print app
-
You need to look up the documentation for
allInstalledApplications
You're currently accessing it wrong
-
I'm an absolute noob with objective-c, so I hoped I can learn from an example.
-
@brumm Your code doesn't look wrong to me (what do you mean exactly, @alijnclarke?), but I don't really understand your question.
-
In objective-c the result is stored in a NSArray.
I thought I can access the single entries, but with the code above I got a single string looking like
<LSApplicationProxy: 0x1........> com.apple.AppStore <file:///Applications/AppStore.app>
...
Is there a way to get only the name of the application? -
Just put this instead of
print app
print app.applicationIdentifier()
-
Great, thanks a lot.
-
Sorry for the vague reply, was in a rush!
There's a couple of options (could be more, but these are all I've needed to use)
app.bundleURL() app.bundleExecutable() app.bundleIdentifier() app.applicationType() app.bundleContainerURL() app.dataContainerURL() app.localizedName()
-
Here you go:
-
Perfect, thanks a lot.
-
By the way, isn't that a huge security loophole? You can easily list all installed applications, get all installed URL schemes, and open any app by bundle ID without the usual user prompt to allow this.
I mean, for scripting and automation this is awesome, but even the private
[UIApplication -launchApplicationWithIdentifier: suspended:]
requires your apps to have root access and define some SpringBoard entitlements. -
It wouldn't get approved by apple as it's a a private api and it's pretty obscure to find.
There's lots of interesting things in the private api's if you go looking!!
-
@lukaskollmer I would be very surprised if this API isn't shut down for third-party apps in one of the next iOS updates. While it is a private API, and you wouldn't get through app review calling it directly, there are obviously lots of ways you could get around those checks...