我正在使用-subpathsOfDirectoryAtPath
NSFileManager 的 API 来检查沙箱中我的 Caches 目录的大小。但奇怪的是,iOS 7 设备的行为有所不同。
API 拒绝列出 iOS 7 设备中所有可用的目录和文件。不过,API 的响应在 iOS 7 模拟器中似乎还不错。iOS 6 SDK 在设备和模拟器中都没有任何问题。我升级到 iOS 7 SDK,现在我仅在设备上就面临这个问题。
我用来查找所有子目录和文件的代码:
NSArray *filesArray = [[NSFileManager defaultManager] subpathsOfDirectoryAtPath:folderPath
error:&fileError];
我检查过它fileError
是零。这意味着 API 正在成功完成它的工作!
但是,当我打印 filesArray 时,我在模拟器和设备中得到不同的响应。我可以向您保证,我在模拟器和设备的沙箱中具有相同的内容,因为我从同一来源提取数据,并且我还将在下面附上相同的快照。
iOS 7 设备filesArray
:
(lldb) po filesArray
<__NSArrayM 0x14571b90>(
ImageCache,
RKClientRequestCache-indiansnakes.org,
RKClientRequestCache-indiansnakes.org/PermanentStore,
RKClientRequestCache-indiansnakes.org/PermanentStore/74738df8d1854e0ad4c6048e7fbdc308,
RKClientRequestCache-indiansnakes.org/PermanentStore/74738df8d1854e0ad4c6048e7fbdc308.headers,
RKClientRequestCache-indiansnakes.org/SessionStore,
Snapshots
)
iOS 7 模拟器filesArray
:
(lldb) po filesArray
<__NSArrayM 0xc453ea0>(
com.jagli.indiansnakes,
com.jagli.indiansnakes/Cache.db,
com.jagli.indiansnakes/Cache.db-shm,
com.jagli.indiansnakes/Cache.db-wal,
com.jagli.indiansnakes/fsCachedData,
ImageCache,
RKClientRequestCache-indiansnakes.org,
RKClientRequestCache-indiansnakes.org/PermanentStore,
RKClientRequestCache-indiansnakes.org/PermanentStore/4fd7c47ab0fe0389c6f3e93bb3b6448c,
RKClientRequestCache-indiansnakes.org/PermanentStore/4fd7c47ab0fe0389c6f3e93bb3b6448c.headers,
RKClientRequestCache-indiansnakes.org/PermanentStore/6c75ce415a2716dd675649e612e81103,
RKClientRequestCache-indiansnakes.org/PermanentStore/6c75ce415a2716dd675649e612e81103.headers,
RKClientRequestCache-indiansnakes.org/PermanentStore/74738df8d1854e0ad4c6048e7fbdc308,
RKClientRequestCache-indiansnakes.org/PermanentStore/74738df8d1854e0ad4c6048e7fbdc308.headers,
RKClientRequestCache-indiansnakes.org/PermanentStore/8c2634b44dd5d3da29c38b197b0f1fe6,
RKClientRequestCache-indiansnakes.org/PermanentStore/8c2634b44dd5d3da29c38b197b0f1fe6.headers,
RKClientRequestCache-indiansnakes.org/PermanentStore/c6e3b72117d11908215af1693754af3f,
RKClientRequestCache-indiansnakes.org/PermanentStore/c6e3b72117d11908215af1693754af3f.headers,
RKClientRequestCache-indiansnakes.org/PermanentStore/cfce42226559ef314867805e658134f1,
RKClientRequestCache-indiansnakes.org/PermanentStore/cfce42226559ef314867805e658134f1.headers,
RKClientRequestCache-indiansnakes.org/SessionStore,
Snapshots,
Snapshots/com.jagli.indiansnakes,
Snapshots/com.jagli.indiansnakes/Main,
Snapshots/com.jagli.indiansnakes/Main/UIApplicationAutomaticSnapshotDefault-Portrait@2x.png,
Three20,
Three20/00d1e10121911d558dbfd64141dcef0b,
Three20/0176adb95ef181f3f376e470515407be,
Three20/022bf0b8fa1b9cdaa9049f99f597f49d,
Three20/02f806ffabe3fcfe6bce321fa4e1231b,
Three20/057debd2a06f07417bc6820d1b9304ed,
Three20/05f6d269c1a7e198e8c8918b1f124c4b,
Three20/0a7ce9f21c0560e0e27cfaa483a253ff,
Three20/0da06fe3edd39fdc5dae47abaa670fb4,
Three20/100d4366e3e928cccd263fa9804a1bdd,
Three20/10fd1ebbadc630616c0c6a41d989dc2a,
Three20/127e92133360dff6a08ecfb087660477,
Three20/1280e9afcc1c334ac5e54be03ea350d5,
Three20/15d6337251920fca03af1f4ecabc6b56,
Three20/18bcc9cb4478d0786cce1b18e474e26d,
Three20/1a9433ca06250061d77556370734c8f5,
Three20/1c77b07c0a7cbfdedd603db36f1286b5,
Three20/281aa8cdbc3d85f97feca841200f47e3,
Three20/2d5d8563516160e4e34282a9b58abe5b,
Three20/301809cb0e34c1a257cc7eaa420d14ed,
Three20/36b0208702eca40fada26b6994e74b45,
Three20/3762f465b5bbdb4b25581786c4cb4c5c,
Three20/3cfdb4630bb21bb784a99e1b703b526b,
Three20/4b6608feb6394f675bb78506486dbd3a,
Three20/4db4d586a4c9d68b69d7a2e158133252,
Three20/5215c70cd2868de6a429002f4b3c16ad,
Three20/5462df992093e3ed5b72ea9f6887d6b8,
Three20/5c2827e499ab79217df994f317ca1ff2,
Three20/6626f4a32279bbcf2a70c9b3e26e27db,
Three20/663bb5de9aeb698923b5e36c8eb43c31,
Three20/710b4e130b6494bca336bcaf2c5fd99d,
Three20/7725b4d768f12c9a3f57ad831c5169eb,
Three20/7af9be05f9ccf312f1561bbd01512b42,
Three20/7cbb43776684ddc26977084938c86bfb,
Three20/841eed7ca99b96cc844a37b02b684953,
Three20/84a67429b1875ac54a6bd9a2fca7fb02,
Three20/8d118946bc8abe1752283c887ae73254,
Three20/91f1eceb43b3363d68da96da085982a3,
Three20/9340302f7f8bc8f752df3f6c96ca5a75,
Three20/98772c3b24849a69b32b08d2c40aa7f4,
Three20/98d0907a5a408cbbeb3cf17ffe2ec9ee,
Three20/9d571ffd47a3eb6d03b8b4d85efa8a33,
Three20/ad24e499780426a1c9ee025f66098bda,
Three20/ad64dc0e42343381d1704f7e4249a9a3,
Three20/b0f05b42788e22b14323a67562e40ac1,
Three20/b2be29e473aad737a769cead95c23e6a,
Three20/b505b10087b332a86d841542ae4ac021,
Three20/b5a1af2586322faec63d18b901fdbfa0,
Three20/b68c96c1ac8a3daedc61df30334cbf18,
Three20/b8b74328816016c3e67fd420703abb73,
Three20/bce04e7ab6a3ed02084c74514a1d5f66,
Three20/c19c7acadf371db6f04c27a46371e16b,
Three20/c244f53752be70826fbf806f501860f4,
Three20/c6e8061e7324b5bd7210a42076bb894d,
Three20/cc5af910d8e927a4017246ba67df7888,
Three20/d07aadf568a0f505f2120c07a84bbdd7,
Three20/d401b8ea86d5951bb126e3aaa11dd781,
Three20/d5d0f328b8554a7b79f194ac30db60c7,
Three20/d5dcb78d9d6282348654eeec382541ba,
Three20/dac14b835a7109fec8ee7d2c73547f80,
Three20/e1d7c76b7dfb7a88ef1de4273f5d3070,
Three20/e2f7ce24b5900a3b9feab9b32aff52e2,
Three20/e65980f08e3964eab5b2d77301c0f97f,
Three20/e67d6d49ea874429dc813a5170a40a60,
Three20/e803b862ed4c571c40a99fbfd75ee8a7,
Three20/e98b2403993127c469c7841d35c90e85,
Three20/eb035236d7c70f3815d3165f7b61aceb,
Three20/f14d0e40ba326c14fd4321d3f4bae5f0,
Three20/f61bc021b4ad11bb8e7718122080436a,
Three20/f710c8decda280789c522082471b1648,
Three20/f82007c3f813be291193aadb9014286d
)
显然-subpathsOfDirectoryAtPath
无法获取设备中的所有路径。为了确认和断言我的观点,文件存在于设备中,请查看此快照:
现在我在应用程序中禁用此功能!