Could not cast value of type Error

Hi,
Does anyone know what causing the following error on line “let obj = dataObjects as! [EventsTable]”

Could not cast value of type ‘__NSDictionaryM’ (0x10dd102b0) to ‘FLBackendlessAPI.EventsTable’ (0x10c056ca0).

I seem to be able to retrieve data plus a lot of meta data but the return value won’t cast to my object type

class EventsTable: NSObject {

var enquiries : String?

var ownerId : String?

var created : Date?

var regional_council : String?

var objectId : String?

var visitors : NSNumber?

var start_date : Date?

var end_date : Date?

var visible_in_app : String?

var event : String?

var organisition : String?

var occurrence_name : String?

var push_code : String?

var updated : Date?

var venue_pointer : Address_UK?

var judgedBy : NSMutableArray?

var timetable_pointer : DATA? 

var results_pointer : DATA?

var syllabus_pointer : DATA?

}

fileprivate func retreiveAllEventDatafromBackendCloud() -> Void {

    let backendless = Backendless.sharedInstance()

    //let eventArray:NSMutableArray = []

    let eventsStorage = backendless?.data.of(EventsTable().ofClass())

    

    let dataQuery = DataQueryBuilder()

    

    //dataQuery?.setWhereClause(self.whereClause)

    //dataQuery?.setRelated(["results_pointer","venue_pointer","syllabus_pointer","judgedBy","timetable_pointer"])

 

    Types.tryblock({ () -> Void in

        // sychronous backendless API call here

        print("Events have been found:")

        

        let dataObjects = eventsStorage?.find(dataQuery)

        

        print(dataObjects)

        

        let obj  = dataObjects as! [EventsTable]

  

       print(obj)

        

    },

                   catchblock: { (exception) -> Void in

                    // handle error from server here

                    //print("backendless Server reported an error: \(String(describing: error))")

                    

                    DispatchQueue.main.async {

                        self.allEventsCompletionHandler(false, nil)

                    }

    })   

}

Regards

Jason

2017-09-19_19-16-31.png

Hi Jason,

A developer will get back to you with an answer shortly.

Regards,
Mark

Hello Jason,
Please provide your Application ID so we could check this issue.

Regards, Olga

…also it would help a lot if you package the sample code into a minimal project so that we could just run it and test the behaviour.

Closed as “cannot answer” without user’s response.