Tutorial details

Save and load data | App Code for Sale | Preview

Save and load data | iOS Tutorial

How to save and load data in your applications

Overview PAGE TOP

Reference: http://www.geekylemon.com/WEBPROTECT-xcode4saveandloadda.htm

In this tutorial i will be showing you how to save and load data in your applications


  • 1 Label
  • 1 Textfield
  • 3 Buttons

Saving and loading data in apps is a major component for games such as saving high scores or loading progress or just generally enabling the user to save and load the data they created within you app

ViewController.h PAGE TOP

@interface ViewController :UIViewController {
IBOutlet UITextField *textfield;
IBOutlet UILabel *label;


ViewController.m PAGE TOP

@implementation ViewController
-(IBAction)settext {
label.text = textfield.text;
-(IBAction)save {
NSString *savestring = label.text;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    [defaults setObject:savestring forKey:@"savedstring"];
    [defaults synchronize];
-(IBAction)load {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *loadstring = [defaults objectForKey:@"savedstring"];
    [label setText:loadstring];

Reference PAGE TOP


0 Comments Leave a comment

Please login in order to leave a comment.

Newest first

to your Chupamobile Account.

The Easiest way to Launch your next App or Game.

Join Chupamobile and get instant access to thousands of ready made App and Game Templates.

Creating an account means you’re okay with Chupamobile’s Terms of Service and Privacy Policy.