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 convert value of type 'AutoreleasingUnsafeMutablePointer<NSArray>' to expected argument type 'AutoreleasingUnsafeMutablePointer<NSArray?>?' #2530

Closed
surayashivji opened this issue Jun 17, 2017 · 5 comments

Comments

@surayashivji
Copy link

I'm getting this issue while trying to run the iOS example code (Objective-C) on the Xcode 9 beta.

Cannot convert value of type 'AutoreleasingUnsafeMutablePointer' to expected argument type 'AutoreleasingUnsafeMutablePointer<NSArray?>?'

screen shot 2017-06-17 at 2 45 11 pm

Does anyone have any idea on a fix?

@liuxuan30
Copy link
Member

I really don't know why you can't run it while I just downloaded xcode 9 beta and simply clicked build and run without any issue.
image
Have you touched anything?

@thierryH91200
Copy link
Contributor

open class func viewFromXib() -> MarkerView?
    {
        #if !os(OSX)
            return Bundle.main.loadNibNamed(
                String(describing: self),
                owner: nil,
                options: nil)?[0] as? MarkerView
        #else
            
            var loadedObjects = NSArray()
            let loadedObjectsPointer = AutoreleasingUnsafeMutablePointer<NSArray?>(&loadedObjects)
            
            if Bundle.main.loadNibNamed(
                String(describing: self),
                owner: nil,
                topLevelObjects: loadedObjectsPointer)
            {
                return loadedObjects[0] as? MarkerView
            }
            
            return nil
        #endif
    }

Types that are pointed to are not bridged. For example, NSString ** comes over to Swift as AutoreleasingUnsafeMutablePointer<NSString?>, not AutoreleasingUnsafeMutablePointer<String?>.

https://developer.apple.com/library/content/documentation/Swift/Conceptual/BuildingCocoaApps/InteractingWithCAPIs.html

@liuxuan30
Copy link
Member

@thierryH91200 what's the cause? I don't see any error on my side.

@surayashivji
Copy link
Author

Worked with that fix! Thanks @thierryH91200 and @liuxuan30

@thierryH91200
Copy link
Contributor

Actually I do not know but I have encountered this problem
I did not do anything extraordinary
Can be a clean build or something else
Without answer

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