<menu id="guoca"></menu>
<nav id="guoca"></nav><xmp id="guoca">
  • <xmp id="guoca">
  • <nav id="guoca"><code id="guoca"></code></nav>
  • <nav id="guoca"><code id="guoca"></code></nav>

    iOS 沙盒有什么特點


    發現錯別字 1年前 提問
    回答
    1
    瀏覽
    244
    請勿發布不友善或者負能量的內容。與人為善,比聰明更重要!
    回答數量: 1
    風險管理(專業級)RM/PL CICSA

    iOS提供沙盒機制,保證我們所有運行的應用都是在一個沙盒模塊里面。沙盒會有這么幾個特點:

    • 每個應用程序都有自己的存儲空間;

    • 應用程序不能直接去訪問別的程序的存儲內容。比如說它不能讀取其他app文件或者內容;

    • 應用程序所請求的數據都要通過權限的檢測。這里所說的請求數據,就是類似于短信,照片等等這些數據,如果我們應用程序要去訪問這些數據,那么他會通過一個權限檢測,讓用戶決定是否允許你去訪問這個數據。

    獲取沙盒的路徑:

    • 獲取沙盒根目錄:

      NSString *homeDirectory = NSHomeDirectory();

      NSLog(@”homeDirectory:%@”, homeDirectory);

    • 獲取document目錄

      NSArray *documentPaths =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

      NSString *documentPath = [documentPaths objectAtIndex:0];

      NSLog(@”documentPath:%@”, documentPath);

    • 獲取Library目錄

      NSArray *libraryPaths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);

      NSString *libraryPath = [libraryPaths objectAtIndex:0];

      NSLog(@”libraryPath:%@”, libraryPath);

    • 獲取Cache目錄

      NSArray *cachePaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);

      NSString *cachePath = [cachePaths objectAtIndex:0];

      NSLog(@”cachePath:%@”, cachePath);

    • 獲取Tmp目錄

      NSString *tmpPath = NSTemporaryDirectory();

      NSLog(@”tmpPath:%@”, tmpPath);

    • bundle路徑

      NSString *bundlePath = [[NSBundle mainBundle] resourcePath];

      NSLog(@”%@”,bundlePath);

      NSString *imagePath = [[NSBundle mainBundle] pathForResource:@”test” ofType:@”png”];

      NSLog(@”%@”,imagePath);

    回答所涉及的環境:聯想天逸510S、Windows 10。

    1年前 / 評論
    亚洲 欧美 自拍 唯美 另类