Serialize and Deserialize Objective-C objects into JSON

Finally we can solve this problem easily using JSONModel. This is the best method so far. JSONModel is a library that generically serialize/deserialize your object based on Class. You can even use non-nsobject based for property like int, short and float. It can also cater nested-complex JSON. Considering this JSON example: { “accounting” : [{ … Read more

How do I get a list of countries in Swift ios?

You can get a list of countries using the NSLocale class’s isoCountryCodes which returns an array of [String]. From there, you get the country name by using NSLocale‘s displayName(forKey:) method. It looks like this: var countries: [String] = [] for code in NSLocale.isoCountryCodes { let id = NSLocale.localeIdentifier(fromComponents: [NSLocale.Key.countryCode.rawValue: code]) let name = NSLocale(localeIdentifier: “en_UK”).displayName(forKey: … Read more

Store [String] in NSUserDefaults

The following code should help you resolve your problem: import UIKit class ViewController: UIViewController { var food: [String] { get { if let returnValue = NSUserDefaults.standardUserDefaults().objectForKey(“food”) as? [String] { return returnValue } else { return [“muesli”, “banana”] //Default value } } set { NSUserDefaults.standardUserDefaults().setObject(newValue, forKey: “food”) NSUserDefaults.standardUserDefaults().synchronize() } } override func viewDidLoad() { super.viewDidLoad() print(food) … Read more

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