什么之间的区别print,NSLog以及println何时该使用的呢?
例如,在Python中,如果我想打印字典,我只是print myDict,但现在我有2个其他选项.我应该如何以及何时使用它们?
我想以编程方式确定iOS应用程序是否直接从XCode运行(在模拟器中或在系留设备上).我已经尝试了这里描述的-D DEBUG解决方案,但是当我从Xcode断开并重新运行应用程序时,它仍然认为它处于调试模式.我认为我正在寻找的是这个函数的Swift版本
#include <assert.h>
#include <stdbool.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/sysctl.h>
static bool AmIBeingDebugged(void)
// Returns true if the current process is being debugged (either
// running under the debugger or has a debugger attached post facto).
{
int junk;
int mib[4];
struct kinfo_proc info;
size_t size;
// Initialize the flags so that, if sysctl fails for some bizarre
// reason, we get a predictable result.
info.kp_proc.p_flag = 0;
// Initialize mib, which tells sysctl …Run Code Online (Sandbox Code Playgroud) 当我在Xcode上调试时,po在Xcode控制台上打印结果大约需要30秒或更长时间.
不幸的是,这只是我在这个问题上的一些信息.
但是,还有另一点需要考虑.此问题非常特定于项目.这是因为当我po在同一台Macbook上使用其他项目时,它会立即生效.此外,这个特殊项目在所有其他Macbook和所有团队中都很慢.
我用谷歌搜索,但没有找到相关的答案.我觉得它很容易使用,print(...)而不是在Xcode控制台上使用调试.但是,它的工作量更大,需要进行大量的重建.