how yo access item key in swift 4

You can try struct Root :Decodable{ let Cities:[InnerItem] } struct InnerItem :Decodable{ let Id:String let Name:String } do { let arr = try JSONDecoder().decode(Root.self, from: data) print(arr.Cities) } catch { print(error) } // Note : This is the correct json structure {“Regions”:null,”Cities”:[{“Id”:”9605″,”Name”:”YANBAA AS SENAYAH”},{“Id”:”15″,”Name”:”ABHA”},{“Id”:”13″,”Name”:”AD DAMMAM”},{“Id”:”1542″,”Name”:”AL BAHA”},{“Id”:”14″,”Name”:”AL MADINAH AL MUNAWWARAH”},{“Id”:”2213″,”Name”:”AR’AR”},{“Id”:”11″,”Name”:”BURAYDAH”},{“Id”:”10″,”Name”:”HAIL”},{“Id”:”17″,”Name”:”JAZAN”},{“Id”:”6″,”Name”:”MAKKAH AL MUKARRAMAH”},{“Id”:”3417″,”Name”:”NAJRAN”},{“Id”:”3″,”Name”:”RIYADH”},{“Id”:”2237″,”Name”:”SAKAKA”},{“Id”:”1″,”Name”:”TABUK”}]}

Can i get iPhone purchase/first time use date [closed]

Short answer: no. Best you can get is information on when the device was turned on #include <sys/sysctl.h> struct timeval boottime; int mib[2] = {CTL_KERN, KERN_BOOTTIME}; size_t size = sizeof(boottime); time_t now; time_t uptime = -1; (void)time(&now); if (sysctl(mib, 2, &boottime, &size, NULL, 0) != -1 && boottime.tv_sec != 0) { uptime = now – … Read more

Add objective c code to swift file [closed]

This is rough translation to Swift…no tested. // Define some colors. var darkGray: UIColor = UIColor.darkGrayColor() var lightGray: UIColor = UIColor.lightGrayColor() // Navigation bar background. UINavigationBar.appearance().barTintColor = darkGray UINavigationBar.appearance().tintColor = lightGray // Color of typed text in the search bar. var searchBarTextAttributes: [NSObject : AnyObject] = [NSForegroundColorAttributeName: lightGray, NSFontAttributeName: UIFont.systemFontOfSize(UIFont.systemFontSize())] UITextField.appearanceWhenContainedInInstancesOfClasses([UISearchBar.self]).defaultTextAttributes = searchBarTextAttributes // Color … Read more

get UITextField Tag in Custom Methods

//yourviewcontroller.h @interface ViewController : UIViewController { int tag; } //yourviewcontroller.m – (void)viewDidLoad { [super viewDidLoad]; tag = 0; } – (BOOL)textFieldShouldBeginEditing:(UITextField *)textField// return NO to disallow editing. { tag = textField.tag; return YES; } – (IBAction)cancelNumberPad:(UITextField*)textField { NSLog(@”The user is typing in text field %d”,tag); } – (IBAction)doneWithNumberPad:(UITextField*)textField { NSLog(@”The user is typing in text … Read more