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

Swift 3 #148

Closed
SebastianKumor opened this issue Oct 8, 2016 · 18 comments
Closed

Swift 3 #148

SebastianKumor opened this issue Oct 8, 2016 · 18 comments

Comments

@SebastianKumor
Copy link
Contributor

How did you resolve this ins swift 3 ?

let yOffset = ((self.columnHeights[section] as AnyObject).object(columnIndex) as AnyObject).doubleValue

gives me error 'Cannot call value of non-function type 'Any?!''

(self.columnHeights[section] as AnyObject).enumerateObjects({(object : AnyObject!, idx : NSInteger,pointer :UnsafeMutablePointer) and this one gives error ' Cannot invoke 'enumerateObjects' with an argument list of type '((AnyObject!, NSInteger, UnsafeMutablePointer) -> ())';

I used Xcode 8 converter and this is the result, thx for help

@gsmeros
Copy link

gsmeros commented Oct 11, 2016

Same here .. any updates ?

@SebastianKumor
Copy link
Contributor Author

I did manage to resolve the errors but the func longestColumnIndexInSection () is crashing m app

@MindaugasJucius
Copy link

MindaugasJucius commented Oct 11, 2016

func shortestColumnIndexInSection (_ section: NSInteger) -> NSInteger {
        var index = 0
        var shorestHeight = MAXFLOAT
        (self.columnHeights[section] as AnyObject).enumerateObjects { (obj: Any, idx: NSInteger, pointer: UnsafeMutablePointer<ObjCBool>) in
            let height = obj as! Float
            if (height<shorestHeight){
                shorestHeight = height
                index = idx
            }
        }
        return index
    }

@SebastianKumor here's how I did it

@SebastianKumor
Copy link
Contributor Author

SebastianKumor commented Oct 11, 2016

@MindaugasJucius thx buddy, it seems like it working, tho I still have crash elsewhere , in a

func prepare() section 3 my yOffset is nil, how are you getting it ? this is what I have let yOffset = ((self.columnHeights[section] as? NSMutableArray)?.object (at: columnIndex) as AnyObject).doubleValue

@chiahsien
Copy link
Owner

The Swift version is contributed by community, I personally don't adopt to Swift yet. So, welcome to send me a PR.

@SebastianKumor
Copy link
Contributor Author

Ok guys thx, I managed to make it work

@gsmeros
Copy link

gsmeros commented Oct 14, 2016

Hello Sebastian , can you please share your CHT file that works ? Thank you in advance.

@SebastianKumor
Copy link
Contributor Author

SebastianKumor commented Oct 14, 2016

@gsmeros @chiahsien I updated the swift file in fork I created, it works for me https://github.com/SebastianKumor/CHTCollectionViewWaterfallLayout
please see if it works as expected, I did not manage to crash it

@rlam3
Copy link

rlam3 commented Oct 19, 2016

@SebastianKumor If it works for you. Please create a new cocoapods for the for the swift version since OP wont support swift. Or create a pull request for OP to create a new branch for? Thanks!

@chiahsien
Copy link
Owner

chiahsien commented Oct 20, 2016

I've merged this PR #149
Can anyone help to test if everything works as expected?

@SebastianKumor
Copy link
Contributor Author

@rlam3 done, can you please also test it if it works as expected ? thanks

@vikht0r
Copy link

vikht0r commented Oct 20, 2016

@SebastianKumor, it works :) . Thanks

@OviBortas
Copy link

I have an Issue when building this in Xcode 8.1, the layout does not take effect. It just lays everything out in one column.

@SebastianKumor
Copy link
Contributor Author

SebastianKumor commented Oct 30, 2016

@OviBortas same here, for me it crashes on func longestColumnIndexInSection()
the issue is cause I believe due to the new handling of optionals implicitly cast as Any in xcode 8.1

@jvk75
Copy link

jvk75 commented Oct 31, 2016

Hi,
I created a pull #152 which makes the swift class more swifty and fixes issues with Xcode8.1

@SebastianKumor
Copy link
Contributor Author

@jvk75 tested, and it works. @OviBortas try new update @jvk75 made

@chiahsien
Copy link
Owner

Hi all, I've merged #152 to develop, also I've merged #151 and #153.
Could anyone help to test if the develop branch works as expected?

@SebastianKumor
Copy link
Contributor Author

Hi @chiahsien , I tested this on xcode 8.1 and swift 3.0.1 and it works well.

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

8 participants