如何从didFinishLaunchingWithOptions调用func应用程序

时间:2019-04-27 15:46:15

标签: ios swift appdelegate

我想知道如何从AppDelegate中的另一个函数调用一个函数。最好从ViewController调用此函数,但无法使其正常工作。

我的 AppDelegate.m 中包含以下代码:

[0AC4:0AC8][2019-04-27T17:40:49]i001: Burn v3.10.1.2213, Windows v6.1 (Build 7600: Service Pack 0), path: C:\Users\MyUser\Desktop\vcredist2017.exe
[0AC4:0AC8][2019-04-27T17:40:49]i009: Command Line: ''
[0AC4:0AC8][2019-04-27T17:40:49]i000: Setting string variable 'WixBundleLog' to value 'C:\Users\MyUser\AppData\Local\Temp\dd_vcredist_x86_20190427174049.log'
[0AC4:0AC8][2019-04-27T17:40:49]i000: Setting string variable 'WixBundleOriginalSource' to value 'C:\Users\MyUser\Desktop\vcredist2017.exe'
[0AC4:0AC8][2019-04-27T17:40:49]i000: Setting string variable 'WixBundleOriginalSourceFolder' to value 'C:\Users\MyUser\Desktop\'
[0AC4:0AC8][2019-04-27T17:40:49]i000: Setting string variable 'WixBundleName' to value 'Microsoft Visual C++ 2017 Redistributable (x86) - 14.16.27027'
[0AC4:0AC8][2019-04-27T17:40:49]i000: Setting string variable 'WixBundleManufacturer' to value 'Microsoft Corporation'
[0AC4:0AD8][2019-04-27T17:40:49]i000: Setting version variable 'WixBundleFileVersion' to value '14.16.27027.1'
[0AC4:0AC8][2019-04-27T17:40:49]i100: Detect begin, 10 packages
[0AC4:0AC8][2019-04-27T17:40:49]i000: File search: windows_uCRT_DetectKey, did not find path: C:\Windows\system32\ucrtbase.dll
[0AC4:0AC8][2019-04-27T17:40:49]i000: File search: windows_uCRT_DetectKeyExists, did not find path: C:\Windows\system32\ucrtbase.dll
[0AC4:0AC8][2019-04-27T17:40:49]i000: Setting numeric variable 'windows_uCRT_DetectKeyExists' to value 0
[0AC4:0AC8][2019-04-27T17:40:49]i052: Condition '(VersionNT = v6.3 AND NOT VersionNT64) AND (windows_uCRT_DetectKeyExists AND windows_uCRT_DetectKey >= v10.0.10240.0)' evaluates to false.
[0AC4:0AC8][2019-04-27T17:40:49]i052: Condition '(VersionNT = v6.3 AND VersionNT64) AND (windows_uCRT_DetectKeyExists AND windows_uCRT_DetectKey >= v10.0.10240.0)' evaluates to false.
[0AC4:0AC8][2019-04-27T17:40:49]i052: Condition '(VersionNT = v6.2 AND NOT VersionNT64) AND (windows_uCRT_DetectKeyExists AND windows_uCRT_DetectKey >= v10.0.10240.0)' evaluates to false.
[0AC4:0AC8][2019-04-27T17:40:49]i052: Condition '(VersionNT = v6.2 AND VersionNT64) AND (windows_uCRT_DetectKeyExists AND windows_uCRT_DetectKey >= v10.0.10240.0)' evaluates to false.
[0AC4:0AC8][2019-04-27T17:40:49]i052: Condition '(VersionNT = v6.1 AND NOT VersionNT64) AND (windows_uCRT_DetectKeyExists AND windows_uCRT_DetectKey >= v10.0.10240.0)' evaluates to false.
[0AC4:0AC8][2019-04-27T17:40:49]i052: Condition '(VersionNT = v6.1 AND VersionNT64) AND (windows_uCRT_DetectKeyExists AND windows_uCRT_DetectKey >= v10.0.10240.0)' evaluates to false.
[0AC4:0AC8][2019-04-27T17:40:49]i052: Condition '(VersionNT = v6.0 AND NOT VersionNT64) AND (windows_uCRT_DetectKeyExists AND windows_uCRT_DetectKey >= v10.0.10240.0)' evaluates to false.
[0AC4:0AC8][2019-04-27T17:40:49]i052: Condition '(VersionNT = v6.0 AND VersionNT64) AND (windows_uCRT_DetectKeyExists AND windows_uCRT_DetectKey >= v10.0.10240.0)' evaluates to false.
[0AC4:0AC8][2019-04-27T17:40:50]i101: Detected package: Windows81_x86, state: Absent, cached: None
[0AC4:0AC8][2019-04-27T17:40:50]i101: Detected package: Windows81_x64, state: Absent, cached: None
[0AC4:0AC8][2019-04-27T17:40:50]i101: Detected package: Windows8_x86, state: Absent, cached: None
[0AC4:0AC8][2019-04-27T17:40:50]i101: Detected package: Windows8_x64, state: Absent, cached: None
[0AC4:0AC8][2019-04-27T17:40:50]i101: Detected package: Windows7_MSU_x86, state: Absent, cached: None
[0AC4:0AC8][2019-04-27T17:40:50]i101: Detected package: Windows7_MSU_x64, state: Absent, cached: Complete
[0AC4:0AC8][2019-04-27T17:40:50]i101: Detected package: WindowsVista_MSU_x86, state: Absent, cached: None
[0AC4:0AC8][2019-04-27T17:40:50]i101: Detected package: WindowsVista_MSU_x64, state: Absent, cached: None
[0AC4:0AC8][2019-04-27T17:40:50]i101: Detected package: vcRuntimeMinimum_x86, state: Absent, cached: Complete
[0AC4:0AC8][2019-04-27T17:40:50]i101: Detected package: vcRuntimeAdditional_x86, state: Absent, cached: Complete
[0AC4:0AC8][2019-04-27T17:40:50]i052: Condition 'VersionNT >= v6.0 OR (VersionNT = v5.1 AND ServicePackLevel >= 2) OR (VersionNT = v5.2 AND ServicePackLevel >= 1)' evaluates to true.
[0AC4:0AC8][2019-04-27T17:40:50]i199: Detect complete, result: 0x0
[0AC4:0AD8][2019-04-27T17:40:52]i000: Setting numeric variable 'EulaAcceptCheckbox' to value 1
[0AC4:0AC8][2019-04-27T17:40:52]i200: Plan begin, 10 packages, action: Install
[0AC4:0AC8][2019-04-27T17:40:52]i052: Condition 'VersionNT = v6.3 AND NOT VersionNT64' evaluates to false.
[0AC4:0AC8][2019-04-27T17:40:52]w321: Skipping dependency registration on package with no dependency providers: Windows81_x86
[0AC4:0AC8][2019-04-27T17:40:52]i052: Condition 'VersionNT = v6.3 AND VersionNT64' evaluates to false.
[0AC4:0AC8][2019-04-27T17:40:52]w321: Skipping dependency registration on package with no dependency providers: Windows81_x64
[0AC4:0AC8][2019-04-27T17:40:52]i052: Condition 'VersionNT = v6.2 AND NOT VersionNT64' evaluates to false.
[0AC4:0AC8][2019-04-27T17:40:52]w321: Skipping dependency registration on package with no dependency providers: Windows8_x86
[0AC4:0AC8][2019-04-27T17:40:52]i052: Condition 'VersionNT = v6.2 AND VersionNT64' evaluates to false.
[0AC4:0AC8][2019-04-27T17:40:52]w321: Skipping dependency registration on package with no dependency providers: Windows8_x64
[0AC4:0AC8][2019-04-27T17:40:52]i052: Condition 'VersionNT = v6.1 AND NOT VersionNT64' evaluates to false.
[0AC4:0AC8][2019-04-27T17:40:52]w321: Skipping dependency registration on package with no dependency providers: Windows7_MSU_x86
[0AC4:0AC8][2019-04-27T17:40:52]i052: Condition 'VersionNT = v6.1 AND VersionNT64' evaluates to true.
[0AC4:0AC8][2019-04-27T17:40:52]w321: Skipping dependency registration on package with no dependency providers: Windows7_MSU_x64
[0AC4:0AC8][2019-04-27T17:40:52]i052: Condition 'VersionNT = v6.0 AND NOT VersionNT64' evaluates to false.
[0AC4:0AC8][2019-04-27T17:40:52]w321: Skipping dependency registration on package with no dependency providers: WindowsVista_MSU_x86
[0AC4:0AC8][2019-04-27T17:40:52]i052: Condition 'VersionNT = v6.0 AND VersionNT64' evaluates to false.
[0AC4:0AC8][2019-04-27T17:40:52]w321: Skipping dependency registration on package with no dependency providers: WindowsVista_MSU_x64
[0AC4:0AC8][2019-04-27T17:40:52]i000: Setting string variable 'WixBundleRollbackLog_vcRuntimeMinimum_x86' to value 'C:\Users\MyUser\AppData\Local\Temp\dd_vcredist_x86_20190427174049_001_vcRuntimeMinimum_x86_rollback.log'
[0AC4:0AC8][2019-04-27T17:40:52]i000: Setting string variable 'WixBundleLog_vcRuntimeMinimum_x86' to value 'C:\Users\MyUser\AppData\Local\Temp\dd_vcredist_x86_20190427174049_001_vcRuntimeMinimum_x86.log'
[0AC4:0AC8][2019-04-27T17:40:52]i000: Setting string variable 'WixBundleRollbackLog_vcRuntimeAdditional_x86' to value 'C:\Users\MyUser\AppData\Local\Temp\dd_vcredist_x86_20190427174049_002_vcRuntimeAdditional_x86_rollback.log'
[0AC4:0AC8][2019-04-27T17:40:52]i000: Setting string variable 'WixBundleLog_vcRuntimeAdditional_x86' to value 'C:\Users\MyUser\AppData\Local\Temp\dd_vcredist_x86_20190427174049_002_vcRuntimeAdditional_x86.log'
[0AC4:0AC8][2019-04-27T17:40:52]i201: Planned package: Windows81_x86, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None
[0AC4:0AC8][2019-04-27T17:40:52]i201: Planned package: Windows81_x64, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None
[0AC4:0AC8][2019-04-27T17:40:52]i201: Planned package: Windows8_x86, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None
[0AC4:0AC8][2019-04-27T17:40:52]i201: Planned package: Windows8_x64, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None
[0AC4:0AC8][2019-04-27T17:40:52]i201: Planned package: Windows7_MSU_x86, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None
[0AC4:0AC8][2019-04-27T17:40:52]i201: Planned package: Windows7_MSU_x64, state: Absent, default requested: Present, ba requested: Present, execute: Install, rollback: Uninstall, cache: No, uncache: No, dependency: None
[0AC4:0AC8][2019-04-27T17:40:52]i201: Planned package: WindowsVista_MSU_x86, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None
[0AC4:0AC8][2019-04-27T17:40:52]i201: Planned package: WindowsVista_MSU_x64, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None
[0AC4:0AC8][2019-04-27T17:40:52]i201: Planned package: vcRuntimeMinimum_x86, state: Absent, default requested: Present, ba requested: Present, execute: Install, rollback: Uninstall, cache: No, uncache: No, dependency: Register
[0AC4:0AC8][2019-04-27T17:40:52]i201: Planned package: vcRuntimeAdditional_x86, state: Absent, default requested: Present, ba requested: Present, execute: Install, rollback: Uninstall, cache: No, uncache: No, dependency: Register
[0AC4:0AC8][2019-04-27T17:40:52]i299: Plan complete, result: 0x0
[0AC4:0AC8][2019-04-27T17:40:52]i300: Apply begin
[0AC4:0AC8][2019-04-27T17:40:52]i010: Launching elevated engine process.
[0AC4:0AC8][2019-04-27T17:40:54]i011: Launched elevated engine process.
[0AC4:0AC8][2019-04-27T17:40:54]i012: Connected to elevated engine.
[0B9C:0BA0][2019-04-27T17:40:54]i358: Pausing automatic updates.
[0B9C:0BA0][2019-04-27T17:40:55]i359: Paused automatic updates.
[0B9C:0BA0][2019-04-27T17:40:55]i360: Creating a system restore point.
[0B9C:0BA0][2019-04-27T17:41:05]i361: Created a system restore point.
[0B9C:0BA0][2019-04-27T17:41:05]i370: Session begin, registration key: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{39e28474-b67b-4209-af1b-e9ad0a83d8ca}, options: 0x7, disable resume: No
[0B9C:0BA0][2019-04-27T17:41:05]i000: Caching bundle from: 'C:\Users\MyUser\AppData\Local\Temp\{39e28474-b67b-4209-af1b-e9ad0a83d8ca}\.be\VC_redist.x86.exe' to: 'C:\ProgramData\Package Cache\{39e28474-b67b-4209-af1b-e9ad0a83d8ca}\VC_redist.x86.exe'
[0B9C:0BA0][2019-04-27T17:41:05]i320: Registering bundle dependency provider: VC,redist.x86,x86,14.16,bundle, version: 14.16.27027.1
[0B9C:0BA0][2019-04-27T17:41:05]i371: Updating session, registration key: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{39e28474-b67b-4209-af1b-e9ad0a83d8ca}, resume: Active, restart initiated: No, disable resume: No
[0B9C:0BB0][2019-04-27T17:41:05]i304: Verified existing payload: Windows7_MSU_x64 at path: C:\ProgramData\Package Cache\54050A5F8AE7F0C56E553F0090146C17A1D2BF8D\packages\Patch\x64\Windows6.1-KB2999226-x64.msu.
[0B9C:0BB0][2019-04-27T17:41:05]i304: Verified existing payload: vcRuntimeMinimum_x86 at path: C:\ProgramData\Package Cache\{5EEFCEFB-E5F7-4C82-99A5-813F04AA4FBD}v14.16.27024\packages\vcRuntimeMinimum_x86\vc_runtimeMinimum_x86.msi.
[0B9C:0BB0][2019-04-27T17:41:05]i304: Verified existing payload: cab54A5CABBE7274D8A22EB58060AAB7623 at path: C:\ProgramData\Package Cache\{5EEFCEFB-E5F7-4C82-99A5-813F04AA4FBD}v14.16.27024\packages\vcRuntimeMinimum_x86\cab1.cab.
[0B9C:0BB0][2019-04-27T17:41:05]i304: Verified existing payload: vcRuntimeAdditional_x86 at path: C:\ProgramData\Package Cache\{7258184A-EC44-4B1A-A7D3-68D85A35BFD0}v14.16.27024\packages\vcRuntimeAdditional_x86\vc_runtimeAdditional_x86.msi.
[0B9C:0BB0][2019-04-27T17:41:06]i304: Verified existing payload: cabB3E1576D1FEFBB979E13B1A5379E0B16 at path: C:\ProgramData\Package Cache\{7258184A-EC44-4B1A-A7D3-68D85A35BFD0}v14.16.27024\packages\vcRuntimeAdditional_x86\cab1.cab.
[0B9C:0BA0][2019-04-27T17:41:06]i301: Applying execute package: Windows7_MSU_x64, action: Install, path: C:\ProgramData\Package Cache\54050A5F8AE7F0C56E553F0090146C17A1D2BF8D\packages\Patch\x64\Windows6.1-KB2999226-x64.msu, arguments: '"C:\Windows\SysNative\wusa.exe" "C:\ProgramData\Package Cache\54050A5F8AE7F0C56E553F0090146C17A1D2BF8D\packages\Patch\x64\Windows6.1-KB2999226-x64.msu" /quiet /norestart'
[0B9C:0BA0][2019-04-27T17:41:11]e000: Error 0x80240017: Failed to execute MSU package.
[0AC4:0AC8][2019-04-27T17:41:11]e000: Error 0x80240017: Failed to configure per-machine MSU package.
[0AC4:0AC8][2019-04-27T17:41:11]i319: Applied execute package: Windows7_MSU_x64, result: 0x80240017, restart: None
[0AC4:0AC8][2019-04-27T17:41:11]e000: Error 0x80240017: Failed to execute MSU package.
[0B9C:0BA0][2019-04-27T17:41:11]i372: Session end, registration key: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{39e28474-b67b-4209-af1b-e9ad0a83d8ca}, resume: None, restart: None, disable resume: No
[0B9C:0BA0][2019-04-27T17:41:11]i330: Removed bundle dependency provider: VC,redist.x86,x86,14.16,bundle
[0B9C:0BA0][2019-04-27T17:41:11]i352: Removing cached bundle: {39e28474-b67b-4209-af1b-e9ad0a83d8ca}, from path: C:\ProgramData\Package Cache\{39e28474-b67b-4209-af1b-e9ad0a83d8ca}\
[0B9C:0BA0][2019-04-27T17:41:11]i371: Updating session, registration key: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{39e28474-b67b-4209-af1b-e9ad0a83d8ca}, resume: None, restart initiated: No, disable resume: No
[0AC4:0AC8][2019-04-27T17:41:11]i399: Apply complete, result: 0x80240017, restart: None, ba requested restart:  No

由于我不知道如何从ViewController.m调用打开url函数,因此我从 AppDelegate.m

调用了func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { let geturl = url.host?.removingPercentEncoding; UserDefaults.standard.set(geturl, forKey: "DeepLinkUrl") return true } func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { //I WANT CALL the upper function to set the URL IN HERE return true } 函数

我的 ViewController.m 如下:

didFinishLaunchingWithOptions

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

您根本不会调用此方法。启动应用程序时,操作系统会调用它。您绝对不应该自己称呼它。

与其他方法相同,当要求您的应用程序打开URL时,操作系统将调用该方法。可能是文件的URL,或者是您注册了方案的URL。

appDidFinishLaunching上设置一个断点,然后在您的viewDidLoad方法上,开始调试以了解发生了什么。您也可以考虑阅读Apple的文档。