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

Code does not compile in iOS 8 Beta 3. #17

Closed
fabriciomrtnz opened this issue Jul 7, 2014 · 6 comments
Closed

Code does not compile in iOS 8 Beta 3. #17

fabriciomrtnz opened this issue Jul 7, 2014 · 6 comments

Comments

@fabriciomrtnz
Copy link

The following line is returning an error:
if let breadcrumb = userInfo["JSONErrorBreadCrumbKey"] as? String{

Error:
'String' is not a subtype of '(NSObject, AnyObject)'

@fabriciomrtnz fabriciomrtnz changed the title Code does not compile in iOS Beta 3. Code does not compile in iOS 8 Beta 3. Jul 7, 2014
@eklipse2k8
Copy link

Interesting, the error goes away if I conditionally cast it to NSString.

    if let userInfo = error.userInfo{
        if let breadcrumb = userInfo["JSONErrorBreadCrumbKey"] as? NSString{
            let newBreadCrumb = (breadcrumb as String) + "/\(index)"
            let newUserInfo = [NSLocalizedDescriptionKey: "JSON Keypath Error: Incorrect Keypath \"\(newBreadCrumb)\"",
                               "JSONErrorBreadCrumbKey": newBreadCrumb]
            return JSONValue.JInvalid(NSError(domain: "JSONErrorDomain", code: 1002, userInfo: newUserInfo))
        }
    }

@fabriciomrtnz
Copy link
Author

Thats the first thing I tried BUT I got the following error:
'NSString' is not convertible to 'UInt8'

By the way I just copied the swift code into a swift file in one of my projects to play around...

@eklipse2k8
Copy link

@fabriciomrtnz make sure to recast breadcrumb as String to get the + operator support.

@fabriciomrtnz
Copy link
Author

Yep that did the trick. Its compiling, let see if it works.

-Thanks Matt

@ElHacker
Copy link

I had the same problem. Changing String to NSStringsolved the issue. Thanks :)

@ghost
Copy link

ghost commented Jul 17, 2014

worked for me as well in Xcode 6 Beta 3

nghuiqin pushed a commit to nghuiqin/SwiftyJSON that referenced this issue Sep 20, 2016
* Kitura/Kitura#675 Required rename of test module and update of Swift version

* Kitura/Kitura#675 Swift language changes

* Kitura/Kitura#675 Foundation changes

* Kitura/Kitura#675 Changes for Linux

* Kitura/Kitura#675 Changes to get Bool working on OSX

* Kitura/Kitura#678 Changes to get tests to work on OSX

* Kitura/Kitura#678 Changes to get tests compiling on OSX

* Kitura/Kitura#675 Test module name changed

* Kitura/Kitura#675 Fix Dictionaries on macOS

* Kitura/Kitura#675 Fix Arrays on macOS

* Kitura/Kitura#675 Test module name changed

* Kitura/Kitura#675 rawValue of Bools is now a Bool. They can't be cast to Int or Double.

* Kitura/Kitura#675 Class of some NSNumber's has changed. compare fails.

* Kitura/Kitura#675 replaced bridge() with new bridge functions

_bridgeToSwift and _bridgeToObjectiveC

* Kitura/Kitura#675 changed signature of dictionary.enumerateKeysAndObjects

to dictionary.enumerateKeysAndObjects(using:
   {(key: Any, val: Any, stop: UnsafeMutablePointer<ObjCBool>)

* Kitura/Kitura#675 unified String.addingPercentEncoding on both Linux and macOS

* Kitura/Kitura#675 one more case of bridge() changed

to _bridgeToObjectiveC()

* Kitura/Kitura#675 removed redundant whitespace

* Kitura/Kitura#675 unified String.addingPercentEncoding on both Linux and macOS

* Kitura/Kitura#675 cast to String instead of NSString

of the key in enumerateKeysAndObjects

* DEVELOPMENT-SNAPSHOT-2016-08-18-a

* Kitura/Kitura#675 removed Indexable

it will be deprecated in Swift 4.0, implementing Collection is enough

* Kitura/Kitura#697 Updated Swift version
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

4 participants