getsling / gvuserdefaults Goto Github PK
View Code? Open in Web Editor NEWNSUserDefaults access via properties.
License: MIT License
NSUserDefaults access via properties.
License: MIT License
generateAccessorMethods
in GVUserDefaults.m not only generate accessor methods for properties in user custom categories, but also generate accessor methods for properties in GVUserDefaults.m itself, namely mapping
and userDefaults
. Probably this is unnecessary?
As far as I can tell, there is no support for observing property value changes via NSNotificationCenter or KVO (or any other method like block-callbacks, for that matter). What are your thoughts on the prospect of this feature?
there is no dynamic key support
When I went up to multiple users to switch , I call transformKey method for each attribute and user name prefix, but only in the program to restart when walk this method, so when program alive multiple users to switch is not
NSUserDefaults has the method initWithSuiteName
But GVUserDefaults has - (NSString *)suitName (notice: suit and not suite).
Might be confusing?
Is it ok to subclass GVUserDefaults?
The reason I asked is because we are planning to use GVUserDefaults in a pod. If an app uses our pod and GVUserDefaults, and both the app and our pod overwrite key prefix with transformKey in the categories, would it create a conflict?
nice project! But when I read the source code in the https://github.com/gangverk/GVUserDefaults/blob/master/GVUserDefaults/GVUserDefaults.m#L125 , I am curious about why use
SEL setupDefaultSEL = NSSelectorFromString([NSString stringWithFormat:@"%@pDefaults", @"setu"]);
not
SEL setupDefaultSEL = NSSelectorFromString(@"setupDefaults");
I'd like to have a place where I can register userdefaults as indicated in the README. At present I have to somewhere in my code call the [[NSUserDefaults standardUserDefaults] registerDefaults:...];
But I'd like to keep the defautls related code in one file, ideally the same category file that I created for all user defaults...
It would be cool if GVUserDefaults can call a method when it is instantiated the similar way transformKey: method is called (when defined)
thanx alot,
Martin
-[NSUserDefaults synchronize] is slow on iOS, and unnecessary on Mac OS X, synchronizing unconditionally on set is virtually never the right choice on either platform
Will initWithSuiteName:
be supported soon?
Int and bool values are not being saved across sessions, even when forcing [[NSUserDefaults standardUserDefaults] synchronize]; after every set. This seems to only be happening on iOS 7.x, 8.x works fine.
Hi. needs help.
I find sometime store property failure.
my category GVUserDefaults (YOSProperties) has property like this:
@Property (nonatomic, weak) NSString *currentLoginID;
when network request success. I save userId in success block:
[GVUserDefaults standardUserDefaults].currentLoginID = model.ID;
It work this time. I can get data from [GVUserDefaults standardUserDefaults].currentLoginID
But reopen my app. It doesn't work. [GVUserDefaults standardUserDefaults].currentLoginID return nil
I replace
[GVUserDefaults standardUserDefaults].currentLoginID = model.ID;
to
[GVUserDefaults standardUserDefaults].currentLoginID = model.ID;
[[NSUserDefaults standardUserDefaults] synchronize];
It works all the time.
thinks.
Objective c properties of course do not quite work in swift, but can similar idea be accomplished in swift? So that it is easy and convenient to access NSUserDefaults via properties in swift?
In the same project,Create the second extended class, no accident value.Can't create two extended classes?Thank you
Hi there,
Firstly thanks for the great contribution!
Would there be any way to change the transformKey at a later time? The use case I have in mind is to enable namespacing the persisted key/values by something dynamic like a UUID.
-James
I've tried to generate a @dynamic NSMutableArray as preferences but it does not work (array become immutable when accessed)
Is this a known limitation?
It seems like call to setupDefaults goes as call to private API. Have you had any issues with submitting an app utilizing this library to AppStore?
Let me describe my question explicitly. For example, I define a key named 'autoSpeak ' in the GVUserDefault's category,and I set its default value is YES in the selector 'setupDefaults'. Then I run my app for the very first time, and log in. The UISwitch controlled by autoSpeak is close. Then I killed my app ,and then run it again,the UISwitch is open now. The same question happened when I switch to another user account.
I looked through the source code. I found setupDefaults is called in the selector init, but the object of GVUserDefault is singleton, so that is the reason, I thought.
Now I solve this problem by called setupDefaults again. But I do not think this is the perfect plan. I wish you, the author, can fix this issue in the source code .
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.