Could not cast value of type 'Events' (0x1022e4c18) to 'DeepEllumiOS.Events' (0x1022e1f48).

app get a crash while casting the response to my custom object.

func getEventData() {

    let whereClause = "isActive = true"

    let queryBuilder = DataQueryBuilder()

    queryBuilder!.setWhereClause(whereClause)

    

    let dataStore = self.backendless.data.of(Events().ofClass())

    dataStore?.find(queryBuilder,

                    response: {

                        (foundEvents) -> () in

                       

                        

                        self.eventsArray = foundEvents as! [Events] // HERE IS CRASH

                        

                        DispatchQueue.main.async {

                            PKHUD.sharedHUD.hide(afterDelay: 1.0) { success in}

                            self.mapVC?.handleDataArray(self.eventsArray)

                        }

                        

    },

                    error: {

                        (fault : Fault?) -> () in

                        print("Server reported an error: \(fault.debugDescription)")

                        if fault?.faultCode! == "3064"{

                            self.viewLoginMenu()

                        }

    })

}

Hi Muhammad,

Please attach also your Events class.

class Events: NSObject {

var objectId:String = ""

//private var _coordinate:CoordinateModel = CoordinateModel(0.0,0.0)

var name:String = ""

var detail:String = ""

var ownerId:String = ""

var eventDateTime:NSDate = NSDate()

var isActive: Bool = true

var created: NSDate?

var updated: NSDate?

var latitude:Double = 0.0

var longitude:Double = 0.0



override init() {

    

}



 init(dict: [String: Any]) {

    super .init()

}

}

Is it possible for you to create a minimal project with only the classes represented here, which would reproduce the problem on launch or on some button click?

sample project attached

added

Bug.zip (17.19MB)

Hi,

please add “@objc(Events)” before your Events class declaration:

@objc(Events)
class Events: NSObject { 
 var objectId:String = ""
 var name:String = ""
...
}

Now it should be fine. iOS-SDK is already compatible with Swift 4, so @objc allows you to write maintain flexibility of untyped access to Objective-C APIs that return id values.
You can see the result attached on the screenshot below.

Regards, Olga

I am using swift 3

and after add this line I am getting linker command failed error.

Screen Shot 2017-11-04 at 4.23.32 PM.png

It is possible that your Events class conflicts with a class with the same name in the SDK. Try to rename your class and table in the app accordingly.

yes I attach the image . it conflicts with your Events file but I can’t update it table name
we have to made changes for admin and android apps also

Screen Shot 2017-11-04 at 7.00.39 PM.png

It’s not necessary to rename your Events table. Just rename the Events class in your project and made the class mapping using this method:

-(void)mapTableToClass:(NSString *)tableName type:(Class)type;

So it would be something like

backendless.data.mapTable(toClass: "Events", type: YOUR-CLASS)

Regards, Olga

cool I like that

i think my problem is solved now .

problem was solved by adding
@objc(Events)
and i rename my model name due to conflicts with backendless sdk.

Thank you for your response. Marked as answered.

Regards, Olga