当用户按下按钮或执行某些操作时如何发送 NSLogs
我正在为某人提出申请,并且我想监控一些事情。我为每个操作都设置了 NSLog,但我希望能够将它们发送到控制台或其他东西。有办法这样做吗?另外,我也不希望用户知道这一点,我正在监视这一点,因为我为用户提供了他必须管理的帐户的密码,并且我想看看他正在做什么以确保他没有违反任何规则。
I'm making an application for someone, and theres some things I'd like to monitor. I have NSLogs all set in place for each action, but I want to be able to send those to a console or something. Is there anyway of doing this? Also I don't want the user to know about it, I'm monitoring this because I gave the user a password for an account he has to manage, and I want to see what he's doing to make sure he's not breaking any rules.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不太明白你想要什么; NSLog() 是输出到控制台的标准函数 - 至少在调试模式下,通常 NSLog() 从发布代码中删除。 (我知道一个大的概括,但通常是正确的)
用户在你的机器上吗?您是否通过网络连接......等等 您遗漏了一些问题。
此外,为什么要给用户选择做违反规则的事情?我认为这应该是您帖子中最重要的一点。用户显然具有违反规则的功能;改变该功能而不是监视它们怎么样?
如果我认为我正在使用的软件正在被“记录”,以便开发人员可以看到我在做什么,我会立即开始寻找替代方案。
编辑:这就是我试图在这个答案的评论中解释的内容。我并不是说这段代码是可以编译的,我只是想解释这样的解决方案应该如何工作。它可能不是最好的,也不是最快的 - 但它会完成工作。我个人仍然认为,如果用户没有理由,就不应该拥有这种功能,并且鉴于您拥有应用程序的源代码,删除该功能应该很简单 - 即使是暂时的。
PHP 脚本 - 这将向您发送错误消息;
然后,要在 Objective-C 中调用它 - 实现一个快速包装函数以使用 NSString 的 stringWithContentsOfURL 方法的功能。像这样......
显然,将末尾的 if 语句替换为实际检查 NSString 内容的内容。这段代码可能会编译,也可能不会编译 - 我没有尝试过,但即使它确实如此,我建议您编写自己的解决方案,因为这是在漫长的几天几乎没有睡眠之后快速编写的!
看,这个应用程序的真正问题不是你在等待用户做他不应该做的事情,而是你让用户能够做他不应该做的事情。不应该。如果您不希望用户做某事,那么就不要向他们提供该功能。在用户已经完成某些操作后等待电子邮件是一个糟糕的主意 - 到那时就为时已晚。在事情发生之前阻止它——不要给他们这样做的选择。积极主动,不要反应迟钝,因为如果用户做了他不应该做的事情;说“但我告诉过你不要这样做!你不被允许”这一切都很好,但你将是那个试图消除他所造成的伤害的人。
I don't quite get what you want here; NSLog() is the standard function to output to the console - at least in debug mode, generally NSLog()'s are removed from release code. (a big generalisation I know, but generally correct)
Is the user on your machine? Are you connected over a network.. etc There's a few questions you've left out.
Furthermore, why are you giving the user the options to do stuff which break the rules? I think this should be the biggest point from your post. The user obviously has the functionality to break the rules; how about changing that functionality instead of spying on them?
If I thought software I was using was being "logged" so the developer could see what I was doing, I would immediately begin looking at alternatives.
Edit: This is what I am trying to explain in the comments of this answer. I'm not claiming this code to be compile-able, I'm merely trying to explain how such a solution should work. It may not be the best, nor the quickest - it will however get the job done. I still personally believe the user shouldn't have that kind of functionality if he has no reason for it, and seeing as you have the source code to the application it should be trivial to remove that functionality - even temporarily.
PHP Script - This will mail you the error;
Then, to call it in Objective-C - implement a quick wrapper function to use the functionality of NSString's stringWithContentsOfURL method. Like this..
Obviously, replacing the if statement at the end for something that will actually check the contents of the NSString. This code may, or may not compile - I haven't tried, but even if it does I advise you to code your own solution as that was written up quickly after a long couple of days with little sleep!
Look, The real issue with this application isn't the fact you're waiting for the user to do something he shouldn't - it's the fact that you're giving that user the ability to do something he shouldn't. If you don't want a user doing something - then don't give them the functionality. It's a poor idea to wait for an email after the user has already done something - by then, its too late. Stop it before it happens - don't give them the option to do it. Be pro-active and not reactionary, because if the user does something he shouldn't; its all fine and well saying "But I told you not to do that! You're not allowed" - but you'll be the one trying to undo the damage he's done.