Using LSApplicationWorkspace in Swift

I added MobileCoreServices.framework to my Xcode project and has a statement import MobileCoreServicesat the top of my file.

I have a line of code

let test = LSApplicationWorkspace.defaultWorkSpace()

And xcode said Unresolved Identifier LSApplicationWorkspace

I tried to clean and rebuild the project. Any ideas?

+3
source share
2 answers

Swift , LSApplicationWorkspace. , , - , . API LSApplicationWorkspace App Store, . , API, ( ) API, , , .

  • , - , LSApplicationWorkspace. LSApplicationWorkspace ( , Mobile CoreServices - , ), App Store, ( ) Objective-C . Apple App Store.

  • NSClassFromString:

let LSApplicationWorkspace_class:AnyObject = NSClassFromString("LSApplicationWorkspace")! as AnyObject
let workspace = LSApplicationWorkspace_class.perform(NSSelectorFromString("defaultWorkspace"))! as AnyObject 

LSApplicationWorkspace, performSelector - , (... , ). , - LSApplicationWorkspace, , .

+4

1: LSApplicationWorkspace api, , , .

2: - , .

.. .h . , google. . , -.

+3

Source: https://habr.com/ru/post/1681417/


All Articles