Use NSUserDefaults: - note that this is for small bits of data, such as the current level like you mentioned. Don't abuse this and use it as a large database, because it is loaded into memory every time you open your app, whether you need something from it or not (other parts of your app will also use this).
Objective-C:
Reading:
NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults];
NSString *currentLevelKey = @"currentlevel";
if ([preferences objectForKey:currentLevelKey] == nil)
{
// Doesn't exist.
}
else
{
// Get current level
const NSInteger currentLevel = [preferences integerForKey:currentLevelKey];
}
Writing:
NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults];
NSString *currentLevelKey = @"currentlevel";
const NSInteger currentLevel = ...;
[preferences setInteger:currentLevel forKey:currentLevelKey];
// Save to disk
const BOOL didSave = [preferences synchronize];
if (!didSave)
{
// Couldn't save (I've never seen this happen in real world testing)
}
.
Swift:
Reading:
let preferences = NSUserDefaults.standardUserDefaults()
let currentLevelKey = "currentLevel"
if preferences.objectForKey(currentLevelKey) == nil {
// Doesn't exist
} else { let currentLevel = preferences.integerForKey(currentLevelKey) //Integer Value
let currentLevel = preferences.objectForKey(currentLevelKey) as! String
let currentLevel = preferences.boolForKey(currentLevelKey)//Boolean value
}
Writing:
let preferences = NSUserDefaults.standardUserDefaults()
let currentLevelKey = "currentLevel"
let currentLevel = ...
preferences.setInteger(currentLevel, forKey: currentLevelKey)
// store string value
preferences.setObject(saveValue, forKey: currentLevelKey)
//
preferences.setBool(saveValue, forKey: currentLevelKey)
// Save to disk
let didSave = preferences.synchronize()
if !didSave {
// Couldn't save (I've never seen this happen in real world testing)
}
ReplyDeleteEagles vs Bengals
Eagles vs Bengals live
nfl game pass
nfl live
live nfl
live nfl on cbs
Dolphins vs Ravens
Dolphins vs Ravens live
nfl game pass
nfl live
live nfl
live nfl on cbs
Bills vs Raiders
Bills vs Raiders live
nfl game pass
nfl live
live nfl
live nfl on cbs
49ers vs Bears
49ers vs Bears live
nfl game pass
nfl live
live nfl
live nfl on cbs
Giants vs Steelers
Giants vs Steelers live
nfl game pass
nfl live
live nfl
live nfl on cbs
Eagles vs Bengals
ReplyDeleteEagles vs Bengals live
nfl game pass
nfl live
live nfl
live nfl on cbs
Dolphins vs Ravens
Dolphins vs Ravens live
nfl game pass
nfl live
live nfl
live nfl on cbs
Bills vs Raiders
Bills vs Raiders live
nfl game pass
nfl live
live nfl
live nfl on cbs
49ers vs Bears
49ers vs Bears live
nfl game pass
nfl live
live nfl
live nfl on cbs
Giants vs Steelers
Giants vs Steelers live
nfl game pass
nfl live
live nfl
live nfl on cbs
Redskins VS Cardinals
ReplyDeleteRedskins VS Cardinals live
nfl game pass
nfl live
live nfl
live nfl on cbs
Buccaneers vs Chargers
Buccaneers vs Chargers live
nfl game pass
nfl live
live nfl
live nfl on cbs
Panthers vs Seahawks
Panthers vs Seahawks live
nfl game pass
nfl live
live nfl
live nfl on cbs
Data Gardener finds and verifies information about specific company and its directors. It develops detailed profiles of target companies with accurate information.Let's follow our website:- https://datagardener.com
ReplyDeleteCustomer Care Number
ReplyDeleteCustomer Care Number
Customer Care Number
Customer Care Number
Customer Care Number
Customer Care Number
Customer Care Number
Customer Care Number
Customer Care Number
Our Bluetooth headphones offer gives a good experience that perfectly fits snugly over your ears.Please check: Bluetooth headphones wireless
ReplyDeleteIf you are looking supply chain finance service in UK then connect with Whitehall Finance.
ReplyDeleteVisit Here:- https://www.whitehallfinance.com/
Call On:- (0203) 369 0098
Nice Blog, When i was read this blog i learnt new things & its truly have well stuff related to developing technology, Thank you for sharing this blog.
ReplyDeleteiPhone app training course in bangalore
Mobile app training institutes bangalore
If you want to become a professional IOS developer. you should learn IOS. By learning IOS you can able to create build views. You can handle user interaction via controls like buttons, switches, and sliders etc. We can also able to display data in a table view. You can create alert boxes, handle navigation and transition between views. You can also follow iOS App Development online Course
ReplyDelete