加速器。属性文件的时间戳

发布于 2024-11-18 03:29:34 字数 111 浏览 2 评论 0原文

钛金SDK版本:1.7.0 iPhone SDK 版本:4.2

我正在创建一个 iOS 应用程序,并使用属性文件作为缓存。 如何获取属性的创建时间(时间戳)?

感谢所有的投入!

Titanium SDK version: 1.7.0
iPhone SDK version: 4.2

I am creating an iOS app and I am using property files as cache.
How can I get the created time (timestamp) for a property?

Thankful for all input!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

红颜悴 2024-11-25 03:29:34

我在我的应用程序中做了类似的事情。我使用时间戳与后端服务器同步数据,因此我编写了一个详细函数以便于访问:

var timestamp = function(){
    return Math.round(new Date().getTime() / 1000);
};

然后

Ti.App.Properties.setString('timestamp', timestamp());

我所做的是将当前时间作为时间戳返回并除以 1000,这将返回 UNIX 时间戳,保持一致与我的后端系统。

将其添加到函数意味着它是可重用的,否则将其分配给变量会执行相同的操作,但该值将始终与初始化应用程序时的值相同。

I do something similar in my apps. I use a timestamp for syncing data with a backend server so I wrote a nitty-gritty function for easy access:

var timestamp = function(){
    return Math.round(new Date().getTime() / 1000);
};

Then

Ti.App.Properties.setString('timestamp', timestamp());

so what I do is return the current time as a timestamp and devide by 1000, this returns a UNIX timestamp, keeping things consistent with my backend system.

Adding it to a function means it's reusable, otherwise assigning it to a variable will do the same thing but the value will always be the same as what it was when initializing the app.

丢了幸福的猪 2024-11-25 03:29:34

在创建该属性的同时,我将创建一个带有时间戳字符串的姐妹属性。

例如:

Titanium.App.Properties.setString("foo","bar");
var timeStamp = String(new Date().getTime());
Titanium.App.Properties.setString("foo_stamp",timeStamp);

据我所知,Property对象没有属性,每个键只有一个值。如果您打算多次执行此操作,我可能会创建一个匿名函数。

At the same time that the property is created, I would just create a sister property with a timestamp string.

For example:

Titanium.App.Properties.setString("foo","bar");
var timeStamp = String(new Date().getTime());
Titanium.App.Properties.setString("foo_stamp",timeStamp);

As far as I know, the Property object has no properties, and only one value per key. I would probably create an anonymous function if you intend to do this more than a few times.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文