zoukankan      html  css  js  c++  java
  • 获取沙盒中路径的方法

    1,获取家目录路径的函数:

    NSString *homeDir = NSHomeDirectory();
    2,获取Documents目录路径的方法:
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *docDir = [paths objectAtIndex:0];
    3,获取Caches目录路径的方法:
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
    NSString *cachesDir = [paths objectAtIndex:0];
    4,获取tmp目录路径的方法:
    NSString *tmpDir = NSTemporaryDirectory();
    5,获取应用程序程序包中资源文件路径的方法:
    例如获取程序包中一个图片资源(apple.png)路径的方法:
    NSString *imagePath = [[NSBundle mainBundle] pathForResource:@”apple” ofType:@”png”];
    UIImage *appleImage = [[UIImage alloc] initWithContentsOfFile:imagePath];
    代码中的mainBundle类方法用于返回一个代表应用程序包的对象。
  • 相关阅读:
    python变量和常量
    python运算符
    python 数据类型强制转换
    Python 变量的缓存机制
    Python格式化输出
    Python 自动类型转换
    Python 六大标准基础数据类型
    Python 基础
    pyhton 初识
    计算机基础
  • 原文地址:https://www.cnblogs.com/likun123/p/3958528.html
Copyright © 2011-2022 走看看