自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

iPhone官方SDK用于讀寫臨時數(shù)據(jù)方法

移動開發(fā) iOS
iPhone官方SDK用于讀寫臨時數(shù)據(jù)方法是本文要介紹的內(nèi)容,我們知道,出于安全考慮,iPhone的官方SDK并不能像toolchain一樣隨意寫文件。感謝waza提供的官方SDK用于讀寫臨時數(shù)據(jù)的方法。

iPhone官方SDK用于讀寫臨時數(shù)據(jù)方法是本文要介紹的內(nèi)容,我們知道,出于安全考慮,iPhone的官方SDK并不能像toolchain一樣隨意寫文件。感謝waza提供的官方SDK用于讀寫臨時數(shù)據(jù)的方法。

  1. bool writeApplicationData(NSData *data, NSString *fileName)  
  2.     {  
  3.         NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);  
  4.         NSString *documentsDirectory = [paths objectAtIndex:0];  
  5.         if (!documentsDirectory) {  
  6.             NSLog(@"Documents directory not found!");  
  7.             return NO;  
  8.         }  
  9.         NSString *appFile = [documentsDirectory stringByAppendingPathComponent:fileName];  
  10.         return ([data writeToFile:appFile atomically:YES]);  
  11.     }  
  12.      
  13. NSData *applicationDataFromFile(NSString *fileName)  
  14.     {  
  15.         NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);  
  16.         NSString *documentsDirectory = [paths objectAtIndex:0];  
  17.         NSString *appFile = [documentsDirectory stringByAppendingPathComponent:fileName];  
  18.         NSData *myData = [[[NSData alloc] initWithContentsOfFile:appFile] autorelease];  
  19.         return myData;  
  20.     } 

iPhone官方SDK用于讀寫臨時數(shù)據(jù)方法

這兩個方法都是存儲在/Documents/里面。

如果你也在使用iPhone的官方SDK進(jìn)行開發(fā),可以在這里和作者討論。

小結(jié):iPhone官方SDK用于讀寫臨時數(shù)據(jù)方法的內(nèi)容介紹完了,希望通過本文的學(xué)習(xí)能對你有所幫助!

責(zé)任編輯:zhaolei 來源: starming社區(qū)
相關(guān)推薦

2011-07-06 17:53:40

iPhone SDK Xcode

2011-08-12 13:19:24

iPhoneSDK安裝

2011-07-21 17:29:42

iPhone Sqlite 數(shù)據(jù)庫

2011-08-18 10:06:10

2021-07-29 08:00:00

開源數(shù)據(jù)技術(shù)

2011-07-19 14:11:07

Windows iPhone SDK

2011-07-21 15:20:31

iPhone SDK 多線程

2011-08-12 14:39:00

iPhoneSDK

2011-07-18 09:35:29

iPhone 框架

2011-07-06 17:40:43

iPhone SDK

2011-08-10 11:12:33

iPhone文件

2011-08-22 12:01:38

iPhone開發(fā)文件

2011-05-31 15:09:02

Android SDK 官方下載

2011-07-18 14:39:53

iPhone SDK UIKit

2011-07-22 18:25:20

XCode iPhone SDK

2021-07-30 07:57:53

Windows 操作系統(tǒng)微軟

2011-07-21 15:05:14

iPhone 數(shù)據(jù)庫

2021-11-17 18:38:32

avaScriptSDK調(diào)試

2011-08-18 10:02:47

iPhone SDKOpenFlow

2011-08-18 09:52:13

iPhone SDKUIPageContr
點贊
收藏

51CTO技術(shù)棧公眾號