In one of my projects, I was using User Defaults for the first time. Then I came across a very interesting problem. I was writing this code for setting value to user defaults:
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
[prefs setObject:@"Value" forKey:@"key"];
After setting the values this way, I tried retrieving the value for the key in next session, it simply did not return correct value.
After googling for a while, I came to know about this line and it worked perfectly:
[prefs synchronize];
Thus, I came to know that in order to use User Defaults, one have to use this synchronize function. The final code looks like:
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
[prefs setObject:@"Value" forKey:@"key"];
[prefs synchronize];
Enjoy!
Subscribe to:
Post Comments (Atom)
Blog Archive
-
►
2008
(15)
-
►
May
(9)
- Competition for MacBook Air
- If you are willing to work
- Some Libraries in JavaScript
- Utility function to get current X and Y position o...
- Utility Class to change local time in GMT and GMT ...
- Interesting Javascript functions
- How to make an image draggable (Google Map Type)
- Life is interesting
- Speed optimization in ASP .Net web applications
-
►
May
(9)
Popular Posts
-
In iPad, we have a new control called UIPopover. This control shows up as an overlay in the screen with a UIViewController or UIView in it. ...
-
Today I came across a unique problem. I was working on a Drupal website for one of my clients and there I was required to create a page to s...
-
/*-------This works for IE and non IE as well----------------*/ var oScript = document.createElement("script"); oScript.src = fileName.js; d...
-
A lot of time I came across a common problem of showing background image in navigation bar of iPhone application. For very first time, I use...
-
While researching about image manipulation for my next project, I came across an interesting piece of code, using which, we can merge two im...
Topics
asp .net
(3)
c#
(2)
Drupal
(3)
How To
(6)
iPhone
(10)
java
(1)
javascript
(8)
laptop
(1)
Life Style
(2)
linux
(1)
logout
(1)
New Technologies
(1)
optimization
(1)
PHP
(2)
planning
(1)
Recession
(1)
resource
(1)
reviews
(1)
secure download
(1)
SEO
(1)
servlet
(1)
skills
(1)
success
(1)
tips
(3)
tutorial
(2)
UIWebView
(1)
Utilities
(4)
web development
(2)
Web technology
(1)
website
(1)
0 comments:
Post a Comment
Tweet