【问题标题】:Call to unavailable function 'system': not available on iOS?调用不可用功能“系统”:在 iOS 上不可用?
【发布时间】:2018-11-06 22:34:10
【问题描述】:

我正在重新审视几年前的源代码,它曾经可以完美编译,但现在项目中有一个错误我无法弄清楚。

我有以下代码:

void AssetsManager::destroyStoragePath()
{
    // Delete recorded version codes.
    deleteVersion();

    // Remove downloaded files
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM ==     CC_PLATFORM_WP8)
    FileUtils::getInstance()->removeDirectory(_storagePath.c_str());
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
    string command = "rd /s /q ";
    // Path may include space.
    command += "\"" + _storagePath + "\"";
    system(command.c_str());
#else
    string command = "rm -r ";
    // Path may include space.
    command += "\"" + _storagePath + "\"";
    system(command.c_str());
#endif
}

NS_CC_EXT_END;`

我收到以下错误:

“调用不可用的函数‘系统’:在 iOS 上不可用”

如何解决这个错误?

【问题讨论】:

  • 要删除资产,您可以使用文件管理器方法removeItem。我不太确定上面的代码你想达到什么目的。

标签: ios iphone xcode


【解决方案1】:

除了系统之外还有几种方法。您可以使用 NSTask(快速处理)

【讨论】:

  • 用 NSProcess 替换“系统”这个词似乎不起作用,它说使用未声明的标识符 'NSProcess'
  • 抱歉是目标 C 中的 NSTask
  • 不是同一件事“使用未声明的标识符'NSTask'”
  • 也许这不适用于 iOS。我们在 macOS 中使用它。这不是你的答案。
  • 好的,我正在寻找 iOS
猜你喜欢
  • 1970-01-01
  • 2018-06-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多