How to store custom objects in NSUserDefaults

On your Player class, implement the following two methods (substituting calls to encodeObject with something relevant to your own object): – (void)encodeWithCoder:(NSCoder *)encoder { //Encode properties, other class variables, etc [encoder encodeObject:self.question forKey:@”question”]; [encoder encodeObject:self.categoryName forKey:@”category”]; [encoder encodeObject:self.subCategoryName forKey:@”subcategory”]; } – (id)initWithCoder:(NSCoder *)decoder { if((self = [super init])) { //decode properties, other class vars self.question … Read more

Clearing NSUserDefaults

You can remove the application’s persistent domain like this: NSString *appDomain = [[NSBundle mainBundle] bundleIdentifier]; [[NSUserDefaults standardUserDefaults] removePersistentDomainForName:appDomain]; In Swift 3 and later: if let bundleID = Bundle.main.bundleIdentifier { UserDefaults.standard.removePersistentDomain(forName: bundleID) } This is similar to the answer by @samvermette but is a little bit cleaner IMO.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)