Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App/Xcode crashing when charts are loaded #410

Closed
BrandonShega opened this issue Sep 23, 2015 · 10 comments
Closed

App/Xcode crashing when charts are loaded #410

BrandonShega opened this issue Sep 23, 2015 · 10 comments

Comments

@BrandonShega
Copy link

We recently updated our app for Xcode 7 and the latest iOS Charts on Swift 2.0 and every time our app loads, it crashes and then Xcode crashes.

The error message that we are receiving is

Can not cast value of type 'Charts.ChartDataEntry' (0x1063ba290) to 'Charts.BarChartDataEntry' (0x1063be5b0).

This is on line 134 in the BarChartDataEntry.swift file.

Any insight would be greatly appreciated.

@liuxuan30
Copy link
Member

Have you checked do you feed wrong dataEntry? It looks like you add ChartDataEntry object but it should be BarChartDataEntry. Check your dataSet first.

@BrandonShega
Copy link
Author

We didn't change anything except the version of Xcode, our app is already on the store working and then we wanted to make it Xcode 7 compatible and it just dies now.

@liuxuan30
Copy link
Member

Then you need to debug or provide more info here... I am still thinking it's wrong data entry class you used. Have you tried the latest master branch? It's been upgraded for swift 2.0

@BrandonShega
Copy link
Author

Yes, after we upgraded to the latest charts and the new version of Xcode, everything went haywire. I don't understand why it would start breaking now when we've had an app on the App Store for about 3 weeks that's worked perfectly fine.

@davidck
Copy link

davidck commented Sep 25, 2015

I ran into the exact same issue.

@liuxuan30
Copy link
Member

@BrandonShega and @davidck, we need more info and logs, and maybe the steps to reproduce it. You are welcome to debug more, since the error message gives you hint.

@BrandonShega
Copy link
Author

@liuxuan30 It looks like it's crashing when we make an array by copying the items of another array. For example we have our array of BarChartDataEntry items and we make a copy of it:

NSMutableArray *currentDataCopy = [[NSMutableArray alloc] initWithArray:self.dashboardItem.currentGraphData copyItems:YES];

Which is then calling

public override func copyWithZone(zone: NSZone) -> AnyObject {}

and this is the method that is crashing and we get the error above in the console about casting.

Any help is greatly appreciated!

@davidck Is this what you are doing as well?

@davidck
Copy link

davidck commented Sep 28, 2015

@BrandonShega I've solved it temporarily by removing lines of codes from the Swift to Obj-C bridging headers. In the generated Swift file, it seems it's holding duplicated references. After removing them, it worked, however, if I rebuild the source, the issue will happen again due to the file being wrongly generated. The issue can be about a mixture of my setup due to my Obj-C project with Cocoapods installed mix with a direct inclusion of the ios-charts framework directly into my project.

@BrandonShega
Copy link
Author

We solved it temporarily by not making copies of the data, maybe these are unrelated issues.

@liuxuan30
Copy link
Member

@BrandonShega seems you are closing to the root cause, you may need to provide a custom copyWithZone function, I am thinking if the ChartEntry needs one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants