Skip to main content

Posts

Showing posts from November, 2022

Core Data Fatch, Save and Delete

    var userListData   = [ NSManagedObject ]()      func fetchData (){         userListData . removeAll ()         let context = ( UIApplication . shared . delegate as ! AppDelegate ). persistentContainer . viewContext         let fetchRequest = NSFetchRequest < NSFetchRequestResult >(entityName: "UserInfo" )         do {             let results = try context. fetch (fetchRequest)             let   dateCreated = results as ! [ NSManagedObject ]             for _datecreated in dateCreated {                 userListData . append (_datecreated)                 tableView . reloadData ()             }         } catch let err as NSError {             print ( err . debugDescription )         }     } ///      func deleteInfo (){         let appDelegate = UIApplication . shared . delegate as ! AppDelegate          let context = appDelegate. persistentContainer . viewContext          let requestDel = NSFetchRequest < NSFetchRequestResult >(entityName: &quo

Array Type JSON Parsing & JSON Serialization

     func   callApi (){         let sessionConfig = URLSessionConfiguration . default         let sessionUrl = URLSession ( configuration : sessionConfig)         let url = URL ( string : "URL" )!         let request: URLRequest = URLRequest ( url :url)         let task = sessionUrl. dataTask ( with : request){             (data, response, error) in             if error != nil {                 print (error!. localizedDescription )             } else {                 do {                     if let json = try ! JSONSerialization . jsonObject ( with : data!, options : . allowFragments ) as ? [ Any ] {                         /*for item in json {                          if let object = item as? [String: Any]{                          print(object)                          }                          }*/                       if let result   = json as ? NSArray {                           for dict in result {                           if let respDict = dict as