Settings

React 实战教程 深入学习一线大厂必备前端技能,VIP 教程限时免费领取。 立即查看 >

Settings是对NSUserDefaults的封装。它是 iOS 平台上的一种持久的键值对存储。

示例#


Reference#

Methods#

clearWatch()#

static clearWatch(watchId: number)

watchId is the number returned by watchKeys() when the subscription was originally configured.

get()#

static get(key: string): mixed

Get the current value for a given key in NSUserDefaults.


set()#

static set(settings: object)

Set one or more values in NSUserDefaults.


watchKeys()#

static watchKeys(keys: string | array<string>, callback: function): number

Subscribe to be notified when the value for any of the keys specified by the keys parameter has been changed in NSUserDefaults. Returns a watchId number that may be used with clearWatch() to unsubscribe.

Note: watchKeys() by design ignores internal set() calls and fires callback only on changes preformed outside of React Native code.


本文档贡献者:sunnylqm(100.00%)#