ios


Swift code compiles fine on iOS, gives warning on OSX: Enum case pattern cannot match values of the non-enum type 'SKPaymentTransactionState`


I have a swift file that I'm using in a couple applications (one being OSX, one being iOS). The code compiles and works fine on iOS, but fails to compile on OSX. Here's the iOS friendly code:
if let transactionsArray = transactions as? [SKPaymentTransaction]{
for transaction in transactionsArray{
switch transaction.transactionState{
case .Failed,.Purchased,.Restored:
queue.finishTransaction(transaction)
default:
break
}
}
}
I can change it to:
if let transactionsArray = transactions as? [SKPaymentTransaction]{
for transaction in transactionsArray{
switch transaction.transactionState{
case SKPaymentTransactionStateFailed, SKPaymentTransactionStatePurchased, SKPaymentTransactionStateRestored:
queue.finishTransaction(transaction)
default:
break
}
}
}
and it'll fix it for OSX— but then iOS throws a fit. I can't seem to come up with anything that'll keep them both happy.
Looking at the documentation, I see that on OSX, SKPaymentTransactionState is define as:
typealias SKPaymentTransactionState = Int
where as on iOS the type is define as:
enum SKPaymentTransactionState : Int {
case Purchasing
case Purchased
case Failed
case Restored
case Deferred
}
I really don't want to do a #if os(iOS)… #else …, so what is the proper way to deal with this discrepancy?

Related Links

prepend item to react native listview without triggering shouldComponentUpdate after adding key to renderRow
Listen for InfowWindow tap in Swift
Create hidden cell under UItableview in Swift
Unrecognised selector sent to instance (keyboardDidShow)
How to import MasterPass library library to project
Xcode 8 - Missing Files warnings
Firebase get child ID swift ios
Swift. Collection of inherited objects
Swift: Extending UIStackView to create a centred list of tags
How to add shadow only at the bottom of section of UITableView?
Creating Multipage PDF File using CoreGraphics shows error on console
iOS Quartz 2D - Fill area between shapes
Is CMPedometer historical data lost on upgrade to iOS10 or a Restore?
Documenting code in Xcode 8
How to get range of specific substring even if a duplicate
iOS SDK SOAP parsing error : Data at the root level is invalid. Line 1, position 1

Categories

HOME
sbt
common-lisp
dicom
linear-programming
textbox
google-adwords
dbus
h2o
wav
xorg
boxfuse
oracle-ucm
aac
coreos
accumulo
amadeus
thrift
advantage-database-server
revitpythonshell
sencha-touch-2
aikau
pvs-studio
android-arrayadapter
reformatting
stl
jtapi
hamcrest
double-click-advertising
texture-mapping
sourcetree
bem
ipod-touch
h5py
es6-promise
plasticscm
logicblox
mdanalysis
gradle-tooling-api
qmake
textangular
rating-system
mrtg
gcc4.8
mashery
jquery-ui-accordion
facebook-canvas
omniauth
mapr
postmark
sqlite-net
atmosphere.js
rails-console
ios-frameworks
groups
asp.net-webpages
id3
js-of-ocaml
subroutine
relaxng
pypdf
autopy
many-to-one
perfview
user-registration
wso2as
information-schema
liferay-hook
mpj-express
razor-2
iphone-privateapi
dynamic-typing
directcompute
team-explorer-everywhere
tinkerpop-frames
xacml3
disk-io
declspec
siblings
str-to-date
glulookat
semantic-markup
xhtml-transitional
alternate-data-stream
squirrelmail
timestamp-with-timezone
vim-fugitive
rgba
mkreversegeocoder
symstore
unitils
excel-web-query
time-estimation
68hc11
corporate-policy

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App