iPhone with File I/O Functions

1. NSHomeDirectory() return the home directory of your application

2. NSTemporaryDirectory() return the temp directory of your application

3. Get document directory:

    NSArray *arrayPaths = NSSearchPathForDirectorysInDomains(NSDocumentDirectory or NSCachesDirectory

                                         NSUserDomainMask,

                                         YES);

    NSString *docDir = [arrayPaths objectAtIndex: 0];

 

4. NSBundle

    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"file" ofType:@"exe"]; //another function with inDictory to search sub directory file

 

5. NSString stringWithContentsOfFile:encoding:error:

    NSString *content = [NSString stringWithContentsOfFile:filePath encoding: NSUTF8StringEncoding error:nil];

 

6. NSString writeFileTo:atomically:encoding:

 

    [content writeToFile:newFilePath atomically: YES encoding:NSUTF8Encoding error:nil];

 

 

iPhone application directory catalog:

drwxr-xr-x mobile mobile Documents /
drwxr-xr-x mobile mobile Library /
drwxr-xr-x mobile mobile Preferences /
drwxr-xr-x mobile mobile MyApp.app/
                         drw-r--r-- mobile mobile _CodeSignature
                         -rw-r--r-- mobile mobile Default.png
                         -rw-r--r-- mobile mobile icon.png
                         -rw-r--r-- mobile mobile Info.plist
                         -rwxr-xr-x mobile mobile MyApp
                         -rw-r--r-- mobile mobile pie.png
                         -rw-r--r-- mobile mobile PkgInfo
                         -rw-r--r-- mobile mobile ResourceRules.plist
drwxr-xr-x mobile mobile tmp /

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值