Registration form on an iphone application - iphone

I have an application developed using iOS5. I have used the storyboard to design the whole screens. The problem I am facing right now is that, when the user runs the application for the very first time, I have to show a view for the user to register. I have no clue on earth on how to do it. I have created the registration forms on the storyboard itself.
Can someone put some light on this issue please?
Thankx in advance.

Try this (and also check this):
Set a value after the user starts the application:
[[NSUserDefaults standardUserDefaults] setValue:[NSNumber numberWithInt:1] forKey:#"registered"];
[[NSUserDefaults standardUserDefaults] synchronize];
and then check with this:
NSNumber *numb=[[NSUserDefaults standardUserDefaults] objectForKey:#"registered"];
if ([numb isEqualToNumber:[NSNumber numberWithInt:1]]) {
NSLog(#"registered");
}else{
NSLog(#"not registered");
}

Related

UIImagePickerController language not changed

In my app used
[[NSUserDefaults standardUserDefaults] setObject:#[#"fr"] forKey:#"AppleLanguages"];
this func to change app language.
It working fine all labels,button and all other elements. but, it is not replicated in UIImagePickerController.
Language change when i kill and reopen the app.
pls any suggestion.
Advance thanks
You need to synchronize your NSUserDefaults and change it like this:
[[NSUserDefaults standardUserDefaults] setValue:#"fr" forKey:#"AppleLanguages"];
[[NSUserDefaults standardUserDefaults] synchronize];
Next you need to use the macro :
NSLocalizedString(string, nil)
for the text inside your UIImagePickerController.
I change in Info.plist file string Localization native development region to my language, and then in app UIImagePickerController changed language. Maybe and for you it will work.

How to make scollView (for T&C) only show up once at begin of app, then never show up again?

My questions is...how to make....this...
I am trying to make a scollview to show the term&condition at beginning of my app when the user is 1st time using the app.
if the user accepted the T&C (by clicking accept button), this T&C scollview will never show up again at beginning of the app, as he already accepted. So he will be free to use the app in future.
How do I implement this? any suggestions?
Use NSUserDefaults with a key like "TCShown". If the key does not exist in the NSUserDefaults at the beginning of the launch, you show the T&C and create "TCShown" value, set it to YES ([NSNumber numberWithBool:YES];) and store it to the NSUserDefaults.
Edit:
Assuming that you want to present the T&C in your first viewController,
#define kTCViewedFlag = #"tcViewed"
-(void) viewDidAppear {
NSUserDefaults *myDefaults = [NSUserDefaults standardUserDefaults];
if(![myDefaults objectForKey:kTCViewedFlag]) {
//show the TC
}
}
-(IBAction) userAcceptedTC {
[[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:YES] forKey:kTCViewedFlag];
[[NSUserDefaults standardUserDefaults] synchronize];
//dismiss the scrollView
}
-(IBAction) userDidDeclineTC {
//handle refusal of TC
}
In addition to Kaan's answer, you can add the TCShown field to the server and update the values accordingly. This will take care of the case when the user who has already accepted the T&C's logs in from a different device.
Maybe you'll find this useful: RLAgreement View Controller
This project allows developers to include
and Agreement, Terms of Service, Non Disclosure Agreement, etc. to an
iPhone App. The controller stores a variable in the user's settings
when the user has a valid agreement and it checks every time the user
opens the App.

How to implement instruction view for iPhone app

I have 2 pages that I want to show as instructions the first time the app is run. How would I accomplish this?
You can utilize NSUserDefaults for something like this.
if(![[NSUserDefaults standardUserDefaults] boolForKey:#"didLoad"]) {
//Show your instructions
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:#"didLoad"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
What this does is, check if the didLoad bool is FALSE (Which will be on first Load), if it is you show your instructions and set the BOOL to YES for the next Launch. You can put this in your viewDidLoad method.

NSUserDefaults is not always saving my NSString data

I'm running into something a bit puzzling. I have some basic string data that I'm trying to save to the NSUserDefaults, like so:
NSString *state = #"finished";
[[NSUserDefaults standardUserDefaults] setObject:state forKey:#"downloadFinished"];
[[NSUserDefaults standardUserDefaults] synchronize];
When the app starts, one of the ways it makes decisions on which view to load is to check the value of this user setting:
NSString *savedState = [[NSUserDefaults standardUserDefaults] stringForKey:#"downloadFinished"]
if(savedState && [savedState length]) {
// Show view
}
Every once in a while, I've noticed that this value fails to load, even though I know for sure that this value was saved previously (or at least, the app tried to save it previously). When this happens, I'm getting a nil value back when I lookup the "downloadFinished" key from the user defaults.
Has anyone run into this before? Is there any knowledge out there on why this might happen? How likely is it that the save to the user's defaults cache and defaults database fails, and is there anyway to further prevent this from happening?
I'm going to try the solution mentioned in Why is NSUserDefaults not saving my values?, which forces another synchronize when the app enters the background, but I'm wondering if anyone has deeper knowledge on the matter.
I am guessing some data type issue here.
Can you try this instead, and see if you get something?
NSString *savedState = [[NSUserDefaults standardUserDefaults] objectForKey:#"downloadFinished"]
Notice objectForKey usage

Loading ModalView only on first open

I've created a modal view that loads on top of my tabBar to serve as a 3 step welcome screen.
While all of that works OK, the problem I'm having is finding a way to load it only once, so that the user doesn't have to deal with a welcome message on every single load.
I've done some research, and it looks like I might be able to call a method with NSTimer, but I'm not sure if that's a proper way to do it.
In your app delegate, set Bool and save in NSUserDefault Check if BOOL is set. If not then present view modally also set the BOOL.
Code might look like this:
In your appdelegate implementatuin. Application didFinishLaunching method:
if (![[NSUserDefaults standardUserDefaults] boolForKey:#"FirstTimeBool"])
{
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:#"FirstTimeBool"];
// present view controller modally after this
}
You can store this information in NSUserDefaults that exactly what's it is for :
At first start :
[[NSUserDefaults standardUserDefaults] setValue:[NSNumber numberWithBool:YES] forKey:#"IS_FIRST_LAUNCH"];
Then to know if it is the first time you run the app :
BOOL isFirstLaunch = [[[NSUserDefaults standardUserDefaults] valueForKey:#"IS_FIRST_LAUNCH"] boolValue]
Hope this helps,
Vincent