Search code examples
swift4uiapplication

how to convert UnsafeMutablePointer<UnsafeMutablePointer<Int8>?> to UnsafeMutablePointer<UnsafeMutablePointer<Int8>>!


I am using swift 4.0 to re-write main.swift of my iOS application. And this is my main.swift:

UIApplicationMain(CommandLine.argc,
              CommandLine.unsafeArgv
              NSStringFromClass(MyAPP.self),
              NSStringFromClass(AppDelegate.self))

there's an compile error here:

Cannot convert value of type 'UnsafeMutablePointer<UnsafeMutablePointer<Int8>?>' to expected argument type 'UnsafeMutablePointer<UnsafeMutablePointer<Int8>>!'

AnyOne know how to convert UnsafeMutablePointer<UnsafeMutablePointer<Int8>?> to UnsafeMutablePointer<UnsafeMutablePointer<Int8>>! here?


Solution

  • Please check :

    UIApplicationMain(  
        CommandLine.argc,  
        UnsafeMutableRawPointer(CommandLine.unsafeArgv)  
            .bindMemory(  
                to: UnsafeMutablePointer<Int8>.self,  
                capacity: Int(CommandLine.argc)
            ),  
        NSStringFromClass(MyAPP.self),  
        NSStringFromClass(AppDelegate.self)  
    )