Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/458.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在共享首选项中存储变量值_Javascript_Iphone_Titanium_Titanium Mobile - Fatal编程技术网

Javascript 在共享首选项中存储变量值

Javascript 在共享首选项中存储变量值,javascript,iphone,titanium,titanium-mobile,Javascript,Iphone,Titanium,Titanium Mobile,我是Tianium和iPhone开发的新手,我想知道如何在共享优先权中存储变量的值,并在另一个js上获取该值?应用程序属性模块用于在应用程序会话和设备电源周期之外持续存在的属性/值对中存储应用程序相关数据 例子 Store a property Store a string property. Ti.App.Properties.setString('givenName', 'Paul'); Ti.API.info('The value of the givenName property is

我是Tianium和iPhone开发的新手,我想知道如何在共享优先权中存储变量的值,并在另一个js上获取该值?

应用程序属性模块用于在应用程序会话和设备电源周期之外持续存在的属性/值对中存储应用程序相关数据

例子

Store a property
Store a string property.

Ti.App.Properties.setString('givenName', 'Paul');
Ti.API.info('The value of the givenName property is: ' + Ti.App.Properties.getString('givenName'));

应用程序属性模块用于将应用程序相关数据存储在属性/值对中,这些属性/值对在应用程序会话和设备电源循环之后仍然存在

例子

Store a property
Store a string property.

Ti.App.Properties.setString('givenName', 'Paul');
Ti.API.info('The value of the givenName property is: ' + Ti.App.Properties.getString('givenName'));

演示钛合金应用程序属性模块使用的简单示例

我正在为service.js中运行的
service\u设置一个布尔值,并在app.js中进行验证

app.js

var isRunning = Ti.App.Properties.getBool("service_running", false);

if (isRunning) 
    Ti.API.info('service is running');
else 
    Ti.API.info('service is not running');
Ti.App.Properties.setBool("service_running", true);
service.js中

var isRunning = Ti.App.Properties.getBool("service_running", false);

if (isRunning) 
    Ti.API.info('service is running');
else 
    Ti.API.info('service is not running');
Ti.App.Properties.setBool("service_running", true);

演示使用钛合金应用程序属性模块的简单示例

我正在为service.js中运行的
service\u设置一个布尔值,并在app.js中进行验证

app.js

var isRunning = Ti.App.Properties.getBool("service_running", false);

if (isRunning) 
    Ti.API.info('service is running');
else 
    Ti.API.info('service is not running');
Ti.App.Properties.setBool("service_running", true);
service.js中

var isRunning = Ti.App.Properties.getBool("service_running", false);

if (isRunning) 
    Ti.API.info('service is running');
else 
    Ti.API.info('service is not running');
Ti.App.Properties.setBool("service_running", true);