iOS将文件保存到非私人目录

时间:2017-08-18 00:39:47

标签: ios objective-c file

现在我正在开发一个从系统上传文件的项目,我想知道是否可以将NSData保存到非私有的位置。基本上,当我现在保存数据时,相应的网址看起来像这样:

{
    "count": 1,
    "page_num": 1,
    "page_no": 1,
    "next": "",
    "previous": "",
    "results": [
        {
            "id": 2,
            "category": {
                "id": 2,
                "create_time": "2017-08-10 16:49:41",
                "update_time": "2017-08-18 08:56:02",
                "name": "test",
                "language_code": "en"
            },
            "create_time": "2017-08-18 08:53:46",
            "update_time": "2017-08-18 09:00:23",
            "cover": "http://192.168.1.108/media/product/20170818-085346-518_59.jpg",
            "view_times": 0,
            "title": "title",
            "summary": "summary",
            "model": "model",
            "price": "91.00",
            "publish_time": "2017-08-18 08:56:04",
            "language_code": "en"
        }
    ]
}

但是当我从UIImagePicker获取文件时,URL看起来像这样:

<?php
// Here $i is your index
$i = 1;
foreach($batsmen as $bat){
    // When the index reaches 10, 24, and 42 then add the three different elements

    // Anything output here is done every iteration of the loop
    // and before your ads

    if( $i == 10 ){
        echo '<div id="ad1"></div>';
    }

    if( $i == 24 ){
        echo '<div id="ad2"></div>';
    }

    if( $i == 42 ){
        echo '<div id="ad3"></div>';
    }

    // Here we are incrementing the index
    $i++;

    // Anything output here is done every iteration of the loop
    // and after your ads
}

我怎样才能(如果可能的话)将数据保存到非私人目录?

仅供参考,这是我到目前为止移动文件的代码:

file:///private/var/mobile/Containers/Data/Application/.../image.jpg

1 个答案:

答案 0 :(得分:1)

没有区别 - /var/private/var的符号链接,因此两条路径都是等效的。