swift error "Default Configuration" and 'NSNull' (0x1b7cc9a28) to 'NSString' (0x1b7cc7ec8).

so i start to make an app and i try so I started an application that allows to make a connection to a database. and i have also 2 signal SIGABRT error i put where the error spawn in my code. I met some errors and unfortunately I don't know how to fix it here is the log:

2022-11-08 18:27:45.563127+0100 test[19072:332743] [SceneConfiguration] Info.plist configuration "Default Configuration" for UIWindowSceneSessionRoleApplication contained UISceneClassName key, but could not load class with name "".
2022-11-08 18:27:45.563460+0100 test[19072:332743] [SceneConfiguration] Info.plist configuration "(no name)" for UIWindowSceneSessionRoleApplication contained UISceneClassName key, but could not load class with name "".
2022-11-08 18:27:45.564063+0100 test[19072:332743] [SceneConfiguration] Info.plist configuration "Default Configuration" for UIWindowSceneSessionRoleApplication contained UISceneClassName key, but could not load class with name "".
Could not cast value of type 'NSNull' (0x1b7cc9a28) to 'NSString' (0x1b7cc7ec8).
2022-11-08 18:27:45.631625+0100 test[19072:332954] Could not cast value of type 'NSNull' (0x1b7cc9a28) to 'NSString' (0x1b7cc7ec8).
Could not cast value of type 'NSNull' (0x1b7cc9a28) to 'NSString' (0x1b7cc7ec8).
CoreSimulator 857.13 - Device: iPhone 14 Pro (6E6732CE-5770-4803-96B8-07D2C8BBAF0E) - Runtime: iOS 16.1 (20B72) - DeviceType: iPhone 14 Pro

here is my homeModel :



import Foundation
import UIKit

protocol HomeModelDelegate {
   
  func itemsDowloaded(client:[Client] )
   
}
class HomeModel : NSObject {
   
  var delegate:HomeModelDelegate?
   
  func getItems(){
    //Hit the conn url
    let serviceURL = "http://localhost/service.php"
    //Download the JSON Data
    let url = URL(string: serviceURL)
     
    if let url = url {
       
      // Create a URL Session
      let session = URLSession(configuration: .default)
       
      let task = session.dataTask(with: url) { (data, url, error) in
         
        if error == nil {
          //Succed
           
          //call the parseJson
          //signal SIGABRT
          self.parseJson(data!)
        }else{
          //error
        }
      }
      // Start the task
      task.resume()
    }
    //notify the view controller and pass the data back
     
  }
   
  func parseJson(_ data:Data){
     
    var clientArray = [Client] //() can't put () because error on the post
    do {
      //Parse the data into Client object
      let jsonArray = try JSONSerialization.jsonObject(with: data, options: []) as! [Any]
       
      //loop through each result in the json array
      for jsonResult in jsonArray {
         
        //Cast json result as a dictionary

        //signal SIGABRT
        let jsonDict = jsonResult as! [String:String]


        //Create a new client and set properties
        let cli = Client(id:jsonDict["id"]!,
                 lastName: jsonDict["nom"]!,
                 firstName: jsonDict["prenom"]!,
                 email: jsonDict["email"]!,
                 mdp: jsonDict["mdp"]!)
       
         
        clientArray.append(cli)
      }
       
      // Pass the client array back to delegation
      delegate?.itemsDowloaded(client: clientArray)
    }
    catch{
      print("error parseJson")
    }
  }
}

Answered by TheNotDevelopper7 in 735696022

Good morning,

so i managed to solve the problem by removing some properties in my client class because the data i was receiving was null, that's probably why i had this error.

for those who have the same problem check well in the php that you did not receive null data or in your database.

I will close the topic.

update on the first signal SIGABRT i write that to to solve the first signal SIGABRT  i


f error == nil {
          //Succed
          if let data = data{
            //call the parseJson
            self.parseJson(data)
          }

Could you post here the info.plist ? There may be an issue with the SceneManifest.

Here is a usual info.plist:

here is my info.splist

Accepted Answer

Good morning,

so i managed to solve the problem by removing some properties in my client class because the data i was receiving was null, that's probably why i had this error.

for those who have the same problem check well in the php that you did not receive null data or in your database.

I will close the topic.

swift error "Default Configuration" and 'NSNull' (0x1b7cc9a28) to 'NSString' (0x1b7cc7ec8).
 
 
Q