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

Cast from BTJSON! to unrelated type String always fail 4.0.0 #195

Closed
nicpro85 opened this issue Nov 10, 2015 · 9 comments
Closed

Cast from BTJSON! to unrelated type String always fail 4.0.0 #195

nicpro85 opened this issue Nov 10, 2015 · 9 comments

Comments

@nicpro85
Copy link

okay I've updated to Braintree 4.0.0 but now when accessing NSDictionary in an NSArray coming from a json parsed with alamofire and accessed using subscript in swift they are considered as BTJSON... wtf

@nicpro85
Copy link
Author

Basically now using responseJSON from Alamofire in swift return BTJSON! object when using subscript so I guess you changed the behavior of the JSON parsing library used by alamofire. or something else

@nicpro85 nicpro85 changed the title Cast from BTJSON! to unrelated type String always fail Cast from BTJSON! to unrelated type String always fail 4.0.0 Nov 10, 2015
@intelliot
Copy link
Contributor

Braintree iOS does not change the behavior of any other JSON parsing library. I believe you may be in touch with Braintree Support and that this issue is now resolved. If the problem persists, it would be helpful if you could provide steps for reproducing the problem (or even better, create a demo project that exhibits the problem). Thanks!

@nicpro85
Copy link
Author

Yes its the same issue. well i dont have the time to replicate the issue as i just say « as! NSDictionary » to solve the problem. I think it might be linked to swift itself or Xcode. no big deal just useless warning appearing.

Thank you for your answer.

regards,

nicolas

Le 18 nov. 2015 à 20:22, Elliot Lee [email protected] a écrit :

Braintree iOS does not change the behavior of any other JSON parsing library. I believe you may be in touch with Braintree Support and that this issue is now resolved. If the problem persists, it would be helpful if you could provide steps for reproducing the problem (or even better, create a demo project that exhibits the problem). Thanks!


Reply to this email directly or view it on GitHub #195 (comment).

@ninh-dws
Copy link

BTJSON conflicted with SwiftyJSON

@galu08
Copy link

galu08 commented Nov 25, 2015

Hi, I have the same problem. I'am using swift 2.0 braintree and Alamofire.

if responseJSON.result.isSuccess {


                if let response = responseJSON.result.value as? [String: AnyObject] {

                    //This have and Alert "Cast from BTJSON to unrelated type 'String' always fails"
                    if let text = response["locale"]?["en_US"]?["s_text"] as? String {
                        terms = text
                    }

                    // This works
                    if let locale = response["locale"] as? [String: AnyObject] {
                        if let en_us = locale["en_US"] as? [String: AnyObject] {
                            if let text = en_us["s_text"] as? String {
                                terms = text
                            }
                        }
                    }
                }
}

@skunkworks
Copy link
Contributor

After getting another report of this issue, we're taking a look at this again.

@skunkworks skunkworks reopened this Dec 8, 2015
@skunkworks
Copy link
Contributor

We've made a preliminary discovery as to the issue -- seems that the Swift compiler is doing strange things due to BTJSON's implementation of objectForKeyedSubscript. We're hoping to have a fix/workaround shortly.

skunkworks pushed a commit that referenced this issue Dec 10, 2015
Fixes issue #195, which is caused by the Swift compiler doing something
weird with the objectForKeyedSubscript implementation in BTJSON.
@skunkworks
Copy link
Contributor

To everyone who has been affected by this issue, please upgrade to 4.1.2. Thanks for your patience.

@nicpro85
Copy link
Author

I did suspected the subscript issue... swift is definitely still work in progress...

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

5 participants