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

Cannot subscript a value of type '[String : AnyObject]' with an index of type 'NSAttributedStringKey' #2777

Closed
bhumit1709 opened this issue Sep 8, 2017 · 9 comments

Comments

@bhumit1709
Copy link

I am getting such errors when I convert to current swift version in Xcode 9 beta

Cannot subscript a value of type '[String : AnyObject]' with an index of type 'NSAttributedStringKey'

ChartViewBase.swift

attrs[NSAttributedStringKey.font] = description.font
attrs[NSAttributedStringKey.foregroundColor] = description.textColor

@hqy2000
Copy link

hqy2000 commented Sep 9, 2017

I found the same issue, and I think that's because the new swift 4 gramma. I changed the swift version from 4.0 to 3.2 in the build settings page, and that solves my problem

@jjatie
Copy link
Collaborator

jjatie commented Sep 10, 2017

Charts is not currently updated for Xcode 9 and Swift 4. This issue has already been resolved in the Swift 4 branch if you would like to see the solution.

@liuxuan30
Copy link
Member

yes. Use swift 4 branch or migrate yourself. We are waiting for Xcode 9 final release to bump our code base.

@youresolutions
Copy link

I am new here, Can you please show when I can find swift 4 branch?

@liuxuan30
Copy link
Member

it's merged

@mmuldoon1
Copy link

I just upgraded to XCode 9 and Swift 4. Charts won't build.
I'm getting the same error:

Cannot subscript a value of type '[String : AnyObject]' with an index of type 'NSAttributedStringKey'
In ChartViewBase.swift.

I unistalled the Pod and reinstalled to insure I had the most up to date branch.

Please advise.
Thanks!

@kiraninfogird
Copy link

kiraninfogird commented Dec 14, 2017

Cannot subscript a value of type 'Dictionary<String, AnyObject?>' with an index of type 'Int'

I am getting an error when handling json, Please help me to solve it?

                if  let mObject = (data as? [String : AnyObject]){
                    if let dictionaryArray = data as? Dictionary<String, AnyObject?> {
                        if dictionaryArray.count > 0 {
                            for i in 0..<dictionaryArray.count{
                                let Object = dictionaryArray[i] // Here is the problem
                                if let empAllotedLeaves = Object["empAllotedLeaves"] as? Int{
                                    print("empAllotedLeaves: \(empAllotedLeaves)")
                                }
                                if let empGetedLeave = Object["empGetedLeave"] as? Int{
                                    print("empGetedLeave: \(empGetedLeave)")
                                }
                            }
                        }
                    }
                }

@jjatie
Copy link
Collaborator

jjatie commented Dec 14, 2017

@kiraninfogird This is not the appropriate forum for this.

@kiraninfogird
Copy link

kiraninfogird commented Dec 15, 2017 via email

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

7 participants