Best way of singleton in Objective-C

It’s very useful during iOS development

static GeneralData __strong *generalDataObject = nil;
@synthesize currentUser;
+(GeneralData *) getInstance
{
static dispatch_once_t pred;
dispatch_once(&pred, ^{
generalDataObject = [self new];
});
return generalDataObject;
}

Usage

  1. Add Data

    firstViewController.m
    #import "GeneralData.h";
    - (IBAction) passValueButton:(id)sender {
    {
    User *user = [User new];
    user.name = "Mary Jane";
    user.age = "21";
    [GeneralData sharedInstance].currentUser = user;
    }
  2. Read Data

    secondViewController.m
    #import "GeneralData.h";
    - (void)viewDidLoad
    {
    [super viewDidLoad];
    User *loggedInUser = [GeneralData sharedInstance].currentUser;
    NSLog(@"Name : %@", loggedInUser.name);
    NSLog(@"Age : %@", loggedInUser.age);
    }

Reference : StackOverflow