你这句话真的惊到我了,我差点信了我不是用Mac回复的帖子,不过你提出来了,我就简单回复一下吧。
有图有真相,先看图
然后看看真相后面隐藏了什么,上代码图,虽然不是很清楚,我可以一句一句给你解释
- 先说说applicationWillFinishLaunching这个函数是干嘛的,是载入程序时调用的,看字面意思也看得出来,注意,只有正常加载完这个函数程序才会正常启动。
- 再来说是下面他干的事情
v3 = objc_msgSend(&OBJC_CLASS___NSBundle, "mainBundle", a3);
v4 = (void *)objc_retainAutoreleasedReturnValue(v3);
v5 = v4;
v6 = objc_msgSend(v4, "bundlePath");
v7 = (void *)objc_retainAutoreleasedReturnValue(v6);
v8 = v7;
v9 = objc_msgSend(v7, "stringByDeletingLastPathComponent");
v10 = (void *)objc_retainAutoreleasedReturnValue(v9);
这几句话就是获取当前程序的运行目录
v11 = objc_msgSend(v10, "lowercaseString");
v12 = (void *)objc_retainAutoreleasedReturnValue(v11);
v13 = (unsigned __int64)objc_msgSend(v12, "isEqualToString:", CFSTR("/applications"));
上面这几句呢,是把获取到的目录转成小写,在和/applications比较是否一致
if ( v13 )
{
if ( (unsigned __int8)+[NeatNsUtils wasLaunchedAsLoginItem](&OBJC_CLASS___NeatNsUtils, "wasLaunchedAsLoginItem")
&& !(unsigned __int8)+[NeatNsUtils getSettingAutoStart](&OBJC_CLASS___NeatNsUtils, "getSettingAutoStart") )
{
objc_msgSend(NSApp, "terminate:", 0LL);
}
}
else
{
+[NeatNsUtils showMessage:description:](
&OBJC_CLASS___NeatNsUtils,
"showMessage:description:",
CFSTR("NeatDownloadManager should run from Applications folder."),
CFSTR("Please Copy NeatDownloadManager.app to \r\n /Applications folder and then run it."));
objc_msgSend(NSApp, "terminate:", 0LL);
}
如果对比是在应用程序目录,就进行一系列的操作,这里我就不展开了
重点是,如果对比结果为否,就是不在应用程序目录,那就弹窗
CFSTR("NeatDownloadManager should run from Applications folder."),
CFSTR("Please Copy NeatDownloadManager.app to \r\n /Applications folder and then run it."));
这就是上面第一张图的结果了
讲到这,请问您还对我没用过Mac有疑问吗
|