BayPhillips / compatible-alert-controller

An iOS7 compatible UIAlertController written in Swift
MIT License
24 stars 6 forks source link

Swift 2.0 Support #9

Closed BayPhillips closed 8 years ago

BayPhillips commented 9 years ago

Swift 2.0 added the ability to mark classes as available based on OS version. The biggest issue we'll have is that you cannot mark individual stored properties as available to different versions. This means that the BPCompatibleAlertController cannot have instances of both UIAlertView _and_ UIAlertController in it.

Anyone have any thoughts on the issue? Maybe we'll have to add a protocol that shows a subclass of ours, one that wraps an UIAlertView and another UIAlertController and have that protocol instantiate them appropriately based off of the OS version? Just an initial idea that I haven't had time to play around with yet.

shovas commented 9 years ago

Ran into this issue now that Xcode 7 GM has been released. While converting the syntax to Swift 2.0 I'm pretty sure you can now mark properties with available?

shovas commented 9 years ago

[Of course I realize after I write it that it reduces the class to one object at a time.]

I'm still migrating syntax so I'm not sure if this tack will pan out but, just as an example, I had the error on BPCompatibleAlertController.alertController ('UIAlertController only available on IOS8') so I made a global in the same file:

@available(iOS 8.0, *) private var BPCompatibleAlertController_alertController:UIAlertController?

And made the class property like this:

@available(iOS 8.0, *) private var alertController: UIAlertController { get { return BPCompatibleAlertController_alertController! } }

Fixed a few other references to BPCompatibleAlertController_alertController with version checks.

It compiles at least. Still need to see if it works.

BayPhillips commented 9 years ago

Hey @shovas, check out the PR here: #10 .

Basically, I don't know how to run iOS 7 simulators via XCode 7 so updating to Swift 2.0 might be a bit tough... (I don't have an iOS 7 device).

adamski commented 9 years ago

I can confirm the Swift 2.0 version works fine on an iPhone 4S running iOS 7.1 :thumbsup:

BayPhillips commented 9 years ago

Hey @adamski, do you mean the PR at #10 ? If so, awesome and perhaps I can merge it into master and make a 1.1 release.

adamski commented 9 years ago

Yes, I tested on the swift-2-support branch.

BayPhillips commented 8 years ago

Thanks for the feedback @adamski . I've merged in my Swift 2 branch and made a 0.0.3 release!