Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 02-07-2012, 09:55 AM   #1 (permalink)
Registered Member
 
Join Date: Jul 2011
Location: Oklahoma City, OK
Posts: 12
okc.engineer is on a distinguished road
Default setting immutable user defaults

Several times when I have removed an app from my iPhone, and later reinstalled it, I have found that, even with the app having been removed, the user default information was still there when the app was restored.

I'd like to do that for my Enterprise app. It has a couple of fields saved to NSUserDefaults, but if my app is deleted from the iPhone and then reinstalled, the NSUserDefault fields have to be re-entered. What I would like to do, similar to the commercial apps I have used, is to have that information reside essentially permanently, available if the app is deleted and re-installed, unless and until the phone is wiped.

My reason for doing this is to eliminate a means of falsifying information. Some of our employees, unfortunately, may sometimes be tempted to make changes in their information in order to cover up some time sheet inaccuracies. Making it virtually impossible -- or at least extremely difficult and inconvenient -- would prevent some of that data misrepresentation.

Is there a way to do this?

Thanks!
okc.engineer is offline   Reply With Quote
Old 02-07-2012, 10:26 AM   #2 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by okc.engineer View Post
Several times when I have removed an app from my iPhone, and later reinstalled it, I have found that, even with the app having been removed, the user default information was still there when the app was restored.

I'd like to do that for my Enterprise app. It has a couple of fields saved to NSUserDefaults, but if my app is deleted from the iPhone and then reinstalled, the NSUserDefault fields have to be re-entered. What I would like to do, similar to the commercial apps I have used, is to have that information reside essentially permanently, available if the app is deleted and re-installed, unless and until the phone is wiped.

My reason for doing this is to eliminate a means of falsifying information. Some of our employees, unfortunately, may sometimes be tempted to make changes in their information in order to cover up some time sheet inaccuracies. Making it virtually impossible -- or at least extremely difficult and inconvenient -- would prevent some of that data misrepresentation.

Is there a way to do this?

Thanks!
It's my understanding that user defaults (NSUserDefaults) gets deleted when you delete an app.

There's another facility, the keychain, that lets you save encrypted information.

The keychain has the facility to save information for a suite of applications.

Say your company, FooSoft, has a family of accounting programs.

Say the bundle name for your apps starts with

com.foosoft.accounting

Then say you have apps

com.foosoft.accounting.gl (general ledger)

and

com.foosoft.accounting.ar (accounts receivable)



You could save keychain info

with the bundle id com.foosoft.accounting, that would be available to all the apps in the com.foosoft.accounting family, and not deleted if you deleted any of the apps in the family.

You should be able to use the keychain to save your information that way, so that deleting a single app does not delete the info.

Disclaimer: I haven't actually done this, just read about it.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is offline   Reply With Quote
Old 02-07-2012, 03:53 PM   #3 (permalink)
Registered Member
 
Join Date: Nov 2009
Location: Helsinki
Posts: 304
fiftysixty is on a distinguished road
Default

Duncan is right, and as luck would have it, I recently had to do a tiny bit of work with the keychain and I came across this:

overhrd Blog Archive A Simple Wrapper Around the iOS Keychain

It's a simple wrapper for storing strings in the keychain. If you need other than strings, you can quite easily modify the wrapper methods to store other data types.
fiftysixty is online now   Reply With Quote
Reply

Bookmarks

Tags
nsuserdefaults, permanent user defaults, user defaults

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 398
14 members and 384 guests
7twenty7, chiataytuday, cristofercolmbos, fiftysixty, gmarro, iOS.Lover, KennyChong, kilobytedump, Matrix23, raymng, ryantcb, stanny, UMAD, xerohuang
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,669
Threads: 94,121
Posts: 402,903
Top Poster: BrianSlick (7,990)
Welcome to our newest member, dedeys78
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:18 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0