是否可以使用新名称保存UIDocument?

时间:2018-06-11 15:57:37

标签: swift uidocument

我试图保存一个名称取决于输入的UIDocument。在下面的简单示例中,我使用了Text Field(nameText.text)中的文本。截至目前,代码正在创建一个空白文档(可能是一个单独的问题)但它只创建一个名称为#34;无标题6","无标题7"等等的文档。

Build Date: 2018-06-11 15:45:50 +0000
--------------------------------------------------------------------------------
PLUGIN OUTPUT
--------------------------------------------------------------------------------
Fetching plugin "cordova-plugin-file@4.3.3" via npm
Installing "cordova-plugin-file" at "4.3.3" for android
Fetching plugin "cordova-plugin-compat@^1.0.0" via npm
Installing "cordova-plugin-compat" at "1.2.0" for android

The Android Persistent storage location now defaults to "Internal". Please check this plugin's README to see if your application needs any changes in its config.xml.

If this is a new application no changes are required.

If this is an update to an existing application that did not specify an "AndroidPersistentFileLocation" you may need to add:

      "<preference name="AndroidPersistentFileLocation" value="Compatibility" />"

to config.xml in order for the application to find previously stored files.
Fetching plugin "cordova-plugin-file-transfer@1.6.3" via npm
Installing "cordova-plugin-file-transfer" at "1.6.3" for android
Plugin dependency "cordova-plugin-file@4.3.3" already fetched, using that version.
Dependent plugin "cordova-plugin-file" already installed on android.
Fetching plugin "cordova-plugin-console@~1.0.0" via npm
Installing "cordova-plugin-console" at "1.0.7" for android
Fetching plugin "cordova-plugin-camera@2.4.1" via npm
Installing "cordova-plugin-camera" at "2.4.1" for android
Plugin dependency "cordova-plugin-compat@1.2.0" already fetched, using that version.
Dependent plugin "cordova-plugin-compat" already installed on android.
Subproject Path: CordovaLib
Fetching plugin "cordova-plugin-media-capture@1.4.3" via npm
Installing "cordova-plugin-media-capture" at "1.4.3" for android
Plugin dependency "cordova-plugin-file@4.3.3" already fetched, using that version.
Dependent plugin "cordova-plugin-file" already installed on android.
Plugin dependency "cordova-plugin-compat@1.2.0" already fetched, using that version.
Dependent plugin "cordova-plugin-compat" already installed on android.
Fetching plugin "cordova-plugin-device@1.1.6" via npm
Installing "cordova-plugin-device" at "1.1.6" for android
Fetching plugin "cordova-plugin-globalization@1.0.7" via npm
Installing "cordova-plugin-globalization" at "1.0.7" for android
Fetching plugin "cordova-plugin-inappbrowser@1.7.1" via npm
Installing "cordova-plugin-inappbrowser" at "1.7.1" for android
Fetching plugin "cordova-plugin-network-information@1.3.3" via npm
Installing "cordova-plugin-network-information" at "1.3.3" for android
Fetching plugin "cordova-plugin-statusbar@2.2.3" via npm
Installing "cordova-plugin-statusbar" at "2.2.3" for android
Fetching plugin "cordova-plugin-whitelist@1.3.2" via npm
Installing "cordova-plugin-whitelist" at "1.3.2" for android

               This plugin is only applicable for versions of cordova-android greater than 4.0. If you have a previous platform version, you do *not* need this plugin since the whitelist will be built in.
Fetching plugin "cordova-plugin-splashscreen@4.0.3" via npm
Installing "cordova-plugin-splashscreen" at "4.0.3" for android
Fetching plugin "cordova-universal-clipboard@0.1.0" via npm
Installing "cordova-universal-clipboard" at "0.1.0" for android
Fetching plugin "nl.kingsquare.cordova.background-audio@1.0.1" via npm
Installing "nl.kingsquare.cordova.background-audio" at "1.0.1" for android
Fetching plugin "phonegap-plugin-push@1.9.2" via npm
Installing "phonegap-plugin-push" at "1.9.2" for android
Subproject Path: CordovaLib
Fetching plugin "cordova-plugin-customurlscheme@4.3.0" via npm
Installing "cordova-plugin-customurlscheme" at "4.3.0" for android
Fetching plugin "ionic-plugin-keyboard@2.2.1" via npm
Installing "ionic-plugin-keyboard" at "2.2.1" for android
Fetching plugin "cordova-plugin-zip@3.1.0" via npm
Installing "cordova-plugin-zip" at "3.1.0" for android
Plugin dependency "cordova-plugin-file@4.3.3" already fetched, using that version.
Dependent plugin "cordova-plugin-file" already installed on android.
Fetching plugin "cordova-plugin-local-notifications-mm" via npm
Installing "cordova-plugin-local-notifications-mm" at "1.0.10" for android
Plugin dependency "cordova-plugin-device@1.1.6" already fetched, using that version.
Dependent plugin "cordova-plugin-device" already installed on android.
Fetching plugin "cordova-plugin-app-event" via npm
Installing "cordova-plugin-app-event" at "1.2.1" for android
Subproject Path: CordovaLib

        Your support is needed. If you use the local-notification plugin please support us in order to ensure further development.
        https://github.com/katzer/cordova-plugin-local-notifications#supporting

        Thank you!
Fetching plugin "https://github.com/Tunts/WebIntent.git" via git clone
Using shallow clone
Repository "https://github.com/Tunts/WebIntent.git" checked out to git ref "master" at "15fcb4e".
Installing "net.tunts.webintent" at "0.2.1" for android
Fetching plugin "https://github.com/ti8m/DocumentHandler.git" via git clone
Using shallow clone
Repository "https://github.com/ti8m/DocumentHandler.git" checked out to git ref "master" at "f501154".
Installing "ch.ti8m.documenthandler" at "0.2.2" for android
--------------------------------------------------------------------------------
PROJECT PROPERTIES
--------------------------------------------------------------------------------
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-25
android.library.reference.1=CordovaLib
cordova.system.library.1=com.android.support:support-v4:24.1.1+
cordova.gradle.include.1=phonegap-plugin-push/moodle-push.gradle
cordova.system.library.2=com.android.support:support-v13:23+
cordova.system.library.3=com.google.android.gms:play-services-gcm:9.8+
cordova.system.library.4=me.leolin:ShortcutBadger:1.1.11@aar
cordova.system.library.5=com.android.support:support-v4:27.1.0
--------------------------------------------------------------------------------
COMPILE OUTPUT
--------------------------------------------------------------------------------
Subproject Path: CordovaLib
Running command: /project/gradlew cdvBuildDebug -b /project/build.gradle -Dorg.gradle.daemon=true -Dorg.gradle.jvmargs=-Xmx2048m -Pandroid.useDeprecatedNdk=true
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
    at build_4vswg8l01ivt4x0mvr9cvmwol.run(/project/build.gradle:138)
The JavaCompile.setDependencyCacheDir() method has been deprecated and is scheduled to be removed in Gradle 4.0.
Incremental java compilation is an incubating feature.
The TaskInputs.source(Object) method has been deprecated and is scheduled to be removed in Gradle 4.0. Please use TaskInputs.file(Object).skipWhenEmpty() instead.
The ProjectDependency.getProjectConfiguration() method has been deprecated and is scheduled to be removed in Gradle 4.0.
ModuleDependency.getConfiguration() has been deprecated and is scheduled to be removed in Gradle 4.0. Use ModuleDependency.getTargetConfiguration() instead.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'project'.
> Could not resolve all dependencies for configuration ':_debugApkCopy'.
   > Could not find com.android.support:support-v4:27.1.0.
     Required by:
         project :
   > Could not find com.android.support:support-v4:27.1.0.
     Required by:
         project :
   > Could not find com.android.support:support-v4:27.1.0.
     Required by:
         project : > com.android.support:support-v13:23.4.0
   > Could not find com.android.support:support-v4:27.1.0.
     Required by:
         project : > com.google.android.gms:play-services-gcm:9.8.0 > com.google.android.gms:play-services-basement:9.8.0

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 1.363 secs
Command finished with error code 1: /project/gradlew cdvBuildDebug,-b,/project/build.gradle,-Dorg.gradle.daemon=true,-Dorg.gradle.jvmargs=-Xmx2048m,-Pandroid.useDeprecatedNdk=true
Error: /project/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'project'.
> Could not resolve all dependencies for configuration ':_debugApkCopy'.
   > Could not find com.android.support:support-v4:27.1.0.
     Required by:
         project :
   > Could not find com.android.support:support-v4:27.1.0.
     Required by:
         project :
   > Could not find com.android.support:support-v4:27.1.0.
     Required by:
         project : > com.android.support:support-v13:23.4.0
   > Could not find com.android.support:support-v4:27.1.0.
     Required by:
         project : > com.google.android.gms:play-services-gcm:9.8.0 > com.google.android.gms:play-services-basement:9.8.0

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
    at ChildProcess.whenDone (/project/cordova/node_modules/cordova-common/src/superspawn.js:169:23)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:877:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

编辑:

我通过添加.appendingPathExtension并将其与.appendingPathComponent一起使用取得了一些进展,如下所示。还在测试。

@IBAction func saveDocument(_ sender: UIButton? = nil) {
    print("...saving...")
    newUrl = try? FileManager.default.url(
        for: .documentDirectory,
        in: .userDomainMask,
        appropriateFor: nil, create: true
        ).appendingPathComponent(nameText.text!+".json")
    let document = CRDocument(fileURL: newUrl!)
    document.cR = cR
    document.updateChangeCount(.done)
    document.save(to: newUrl!, for: .forCreating)
}

0 个答案:

没有答案
相关问题