Documentation Archive Developer
Search

StoreKit Changes for Swift

StoreKit

Removed SKDownloadState.value
Added SKDownloadState.init(rawValue: Int)
Added SKDownloadState.rawValue
Modified SKDownload
Declaration
From
class SKDownload : NSObject {
    var contentIdentifier: String! { get }
    var state: SKDownloadState { get }
    @NSCopying var contentURL: NSURL! { get }
    var progress: Float { get }
    @NSCopying var error: NSError! { get }
    var timeRemaining: NSTimeInterval { get }
    @NSCopying var contentLength: NSNumber! { get }
    var contentVersion: String! { get }
    class func contentURLForProductID(_ productID: String!) -> NSURL!
    class func deleteContentForProductID(_ productID: String!)
}
To
class SKDownload : NSObject {
    var contentIdentifier: String { get }
    var state: SKDownloadState { get }
    @NSCopying var contentURL: NSURL? { get }
    var progress: Float { get }
    @NSCopying var error: NSError? { get }
    var timeRemaining: NSTimeInterval { get }
    @NSCopying var contentLength: NSNumber { get }
    var contentVersion: String? { get }
    var transaction: SKPaymentTransaction? { get }
    class func contentURLForProductID(_ productID: String) -> NSURL?
    class func deleteContentForProductID(_ productID: String)
}

Declaration
From
var contentIdentifier: String! { get }
To
var contentIdentifier: String { get }

Declaration
From
@NSCopying var contentLength: NSNumber! { get }
To
@NSCopying var contentLength: NSNumber { get }

Declaration
From
@NSCopying var contentURL: NSURL! { get }
To
@NSCopying var contentURL: NSURL? { get }

Declaration
From
class func contentURLForProductID(_ productID: String!) -> NSURL!
To
class func contentURLForProductID(_ productID: String) -> NSURL?

Declaration
From
var contentVersion: String! { get }
To
var contentVersion: String? { get }

Declaration
From
class func deleteContentForProductID(_ productID: String!)
To
class func deleteContentForProductID(_ productID: String)

Declaration
From
@NSCopying var error: NSError! { get }
To
@NSCopying var error: NSError? { get }

DeclarationProtocols
From
struct SKDownloadState {
    init(_ value: Int)
    var value: Int
}
--
To
struct SKDownloadState : RawRepresentable {
    init(_ rawValue: Int)
    init(rawValue rawValue: Int)
    var rawValue: Int
}
RawRepresentable

Declaration
From
class SKMutablePayment : SKPayment {
    var productIdentifier: String!
    var quantity: Int
    @NSCopying var requestData: NSData!
    var applicationUsername: String!
}
To
class SKMutablePayment : SKPayment {
    var productIdentifier: String
    var quantity: Int
    @NSCopying var requestData: NSData?
    var applicationUsername: String?
}

Declaration
From
var applicationUsername: String!
To
var applicationUsername: String?

Declaration
From
var productIdentifier: String!
To
var productIdentifier: String

Declaration
From
@NSCopying var requestData: NSData!
To
@NSCopying var requestData: NSData?

Modified SKPayment
Declaration
From
class SKPayment : NSObject, NSCopying, NSMutableCopying {
    class func paymentWithProduct(_ product: SKProduct!) -> AnyObject!
    var productIdentifier: String! { get }
    @NSCopying var requestData: NSData! { get }
    var quantity: Int { get }
    var applicationUsername: String! { get }
}
To
class SKPayment : NSObject, NSCopying, NSMutableCopying {
    class func paymentWithProduct(_ product: SKProduct) -> AnyObject
    var productIdentifier: String { get }
    @NSCopying var requestData: NSData? { get }
    var quantity: Int { get }
    var applicationUsername: String? { get }
}

Declaration
From
var applicationUsername: String! { get }
To
var applicationUsername: String? { get }

Declaration
From
class func paymentWithProduct(_ product: SKProduct!) -> AnyObject!
To
class func paymentWithProduct(_ product: SKProduct) -> AnyObject

Declaration
From
var productIdentifier: String! { get }
To
var productIdentifier: String { get }

Declaration
From
@NSCopying var requestData: NSData! { get }
To
@NSCopying var requestData: NSData? { get }

Declaration
From
class SKPaymentQueue : NSObject {
    class func defaultQueue() -> SKPaymentQueue!
    class func canMakePayments() -> Bool
    func addPayment(_ payment: SKPayment!)
    func restoreCompletedTransactions()
    func restoreCompletedTransactionsWithApplicationUsername(_ username: String!)
    func finishTransaction(_ transaction: SKPaymentTransaction!)
    func addTransactionObserver(_ observer: SKPaymentTransactionObserver!)
    func removeTransactionObserver(_ observer: SKPaymentTransactionObserver!)
    var transactions: [AnyObject]! { get }
    func startDownloads(_ downloads: [AnyObject]!)
    func pauseDownloads(_ downloads: [AnyObject]!)
    func resumeDownloads(_ downloads: [AnyObject]!)
    func cancelDownloads(_ downloads: [AnyObject]!)
}
To
class SKPaymentQueue : NSObject {
    class func defaultQueue() -> SKPaymentQueue
    class func canMakePayments() -> Bool
    func addPayment(_ payment: SKPayment)
    func restoreCompletedTransactions()
    func restoreCompletedTransactionsWithApplicationUsername(_ username: String?)
    func finishTransaction(_ transaction: SKPaymentTransaction)
    func addTransactionObserver(_ observer: SKPaymentTransactionObserver)
    func removeTransactionObserver(_ observer: SKPaymentTransactionObserver)
    var transactions: [SKPaymentTransaction]? { get }
    func startDownloads(_ downloads: [SKDownload])
    func pauseDownloads(_ downloads: [SKDownload])
    func resumeDownloads(_ downloads: [SKDownload])
    func cancelDownloads(_ downloads: [SKDownload])
}

Declaration
From
func addPayment(_ payment: SKPayment!)
To
func addPayment(_ payment: SKPayment)

Declaration
From
func addTransactionObserver(_ observer: SKPaymentTransactionObserver!)
To
func addTransactionObserver(_ observer: SKPaymentTransactionObserver)

Declaration
From
func cancelDownloads(_ downloads: [AnyObject]!)
To
func cancelDownloads(_ downloads: [SKDownload])

Declaration
From
class func defaultQueue() -> SKPaymentQueue!
To
class func defaultQueue() -> SKPaymentQueue

Declaration
From
func finishTransaction(_ transaction: SKPaymentTransaction!)
To
func finishTransaction(_ transaction: SKPaymentTransaction)

Declaration
From
func pauseDownloads(_ downloads: [AnyObject]!)
To
func pauseDownloads(_ downloads: [SKDownload])

Declaration
From
func removeTransactionObserver(_ observer: SKPaymentTransactionObserver!)
To
func removeTransactionObserver(_ observer: SKPaymentTransactionObserver)

Declaration
From
func restoreCompletedTransactionsWithApplicationUsername(_ username: String!)
To
func restoreCompletedTransactionsWithApplicationUsername(_ username: String?)

Declaration
From
func resumeDownloads(_ downloads: [AnyObject]!)
To
func resumeDownloads(_ downloads: [SKDownload])

Declaration
From
func startDownloads(_ downloads: [AnyObject]!)
To
func startDownloads(_ downloads: [SKDownload])

Declaration
From
var transactions: [AnyObject]! { get }
To
var transactions: [SKPaymentTransaction]? { get }

Declaration
From
class SKPaymentTransaction : NSObject {
    var error: NSError! { get }
    var originalTransaction: SKPaymentTransaction! { get }
    var payment: SKPayment! { get }
    var transactionDate: NSDate! { get }
    var transactionIdentifier: String! { get }
    var downloads: [AnyObject]! { get }
    var transactionState: SKPaymentTransactionState { get }
}
To
class SKPaymentTransaction : NSObject {
    var error: NSError? { get }
    var originalTransaction: SKPaymentTransaction? { get }
    var payment: SKPayment { get }
    var transactionDate: NSDate? { get }
    var transactionIdentifier: String? { get }
    var downloads: [AnyObject]? { get }
    var transactionState: SKPaymentTransactionState { get }
}

Declaration
From
var downloads: [AnyObject]! { get }
To
var downloads: [AnyObject]? { get }

Declaration
From
var error: NSError! { get }
To
var error: NSError? { get }

Declaration
From
var originalTransaction: SKPaymentTransaction! { get }
To
var originalTransaction: SKPaymentTransaction? { get }

Declaration
From
var payment: SKPayment! { get }
To
var payment: SKPayment { get }

Declaration
From
var transactionDate: NSDate! { get }
To
var transactionDate: NSDate? { get }

Declaration
From
var transactionIdentifier: String! { get }
To
var transactionIdentifier: String? { get }

Declaration
From
protocol SKPaymentTransactionObserver : NSObjectProtocol {
    func paymentQueue(_ queue: SKPaymentQueue!, updatedTransactions transactions: [AnyObject]!)
    optional func paymentQueue(_ queue: SKPaymentQueue!, removedTransactions transactions: [AnyObject]!)
    optional func paymentQueue(_ queue: SKPaymentQueue!, restoreCompletedTransactionsFailedWithError error: NSError!)
    optional func paymentQueueRestoreCompletedTransactionsFinished(_ queue: SKPaymentQueue!)
    optional func paymentQueue(_ queue: SKPaymentQueue!, updatedDownloads downloads: [AnyObject]!)
}
To
protocol SKPaymentTransactionObserver : NSObjectProtocol {
    func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction])
    optional func paymentQueue(_ queue: SKPaymentQueue, removedTransactions transactions: [SKPaymentTransaction])
    optional func paymentQueue(_ queue: SKPaymentQueue, restoreCompletedTransactionsFailedWithError error: NSError)
    optional func paymentQueueRestoreCompletedTransactionsFinished(_ queue: SKPaymentQueue)
    optional func paymentQueue(_ queue: SKPaymentQueue, updatedDownloads downloads: [SKDownload])
}

DeclarationIntroduction
From
optional func paymentQueue(_ queue: SKPaymentQueue!, removedTransactions transactions: [AnyObject]!)
OS X 10.10
To
optional func paymentQueue(_ queue: SKPaymentQueue, removedTransactions transactions: [SKPaymentTransaction])
OS X 10.7

DeclarationIntroduction
From
optional func paymentQueue(_ queue: SKPaymentQueue!, restoreCompletedTransactionsFailedWithError error: NSError!)
OS X 10.10
To
optional func paymentQueue(_ queue: SKPaymentQueue, restoreCompletedTransactionsFailedWithError error: NSError)
OS X 10.7

DeclarationIntroduction
From
optional func paymentQueue(_ queue: SKPaymentQueue!, updatedDownloads downloads: [AnyObject]!)
OS X 10.10
To
optional func paymentQueue(_ queue: SKPaymentQueue, updatedDownloads downloads: [SKDownload])
OS X 10.8

DeclarationIntroduction
From
func paymentQueue(_ queue: SKPaymentQueue!, updatedTransactions transactions: [AnyObject]!)
OS X 10.10
To
func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction])
OS X 10.7

DeclarationIntroduction
From
optional func paymentQueueRestoreCompletedTransactionsFinished(_ queue: SKPaymentQueue!)
OS X 10.10
To
optional func paymentQueueRestoreCompletedTransactionsFinished(_ queue: SKPaymentQueue)
OS X 10.7

Modified SKProduct
Declaration
From
class SKProduct : NSObject {
    var localizedDescription: String! { get }
    var localizedTitle: String! { get }
    var price: NSDecimalNumber! { get }
    var priceLocale: NSLocale! { get }
    var productIdentifier: String! { get }
    var downloadable: Bool { get }
    var contentVersion: String! { get }
    var contentLengths: [AnyObject]! { get }
}
To
class SKProduct : NSObject {
    var localizedDescription: String? { get }
    var localizedTitle: String? { get }
    var price: NSDecimalNumber? { get }
    var priceLocale: NSLocale? { get }
    var productIdentifier: String? { get }
    var downloadable: Bool { get }
    var contentVersion: String? { get }
    var contentLengths: [NSNumber]? { get }
}

Declaration
From
var contentLengths: [AnyObject]! { get }
To
var contentLengths: [NSNumber]? { get }

Declaration
From
var contentVersion: String! { get }
To
var contentVersion: String? { get }

Declaration
From
var localizedDescription: String! { get }
To
var localizedDescription: String? { get }

Declaration
From
var localizedTitle: String! { get }
To
var localizedTitle: String? { get }

Declaration
From
var price: NSDecimalNumber! { get }
To
var price: NSDecimalNumber? { get }

Declaration
From
var priceLocale: NSLocale! { get }
To
var priceLocale: NSLocale? { get }

Declaration
From
var productIdentifier: String! { get }
To
var productIdentifier: String? { get }

Declaration
From
class SKProductsRequest : SKRequest {
    init!(productIdentifiers productIdentifiers: Set<NSObject>!)
    unowned(unsafe) var delegate: SKProductsRequestDelegate!
}
To
class SKProductsRequest : SKRequest {
    init(productIdentifiers productIdentifiers: Set<NSObject>)
    unowned(unsafe) var delegate: SKProductsRequestDelegate?
}

Declaration
From
unowned(unsafe) var delegate: SKProductsRequestDelegate!
To
unowned(unsafe) var delegate: SKProductsRequestDelegate?

Declaration
From
init!(productIdentifiers productIdentifiers: Set<NSObject>!)
To
init(productIdentifiers productIdentifiers: Set<NSObject>)

Declaration
From
protocol SKProductsRequestDelegate : SKRequestDelegate, NSObjectProtocol {
    func productsRequest(_ request: SKProductsRequest!, didReceiveResponse response: SKProductsResponse!)
}
To
protocol SKProductsRequestDelegate : SKRequestDelegate, NSObjectProtocol {
    func productsRequest(_ request: SKProductsRequest, didReceiveResponse response: SKProductsResponse)
}

DeclarationIntroduction
From
func productsRequest(_ request: SKProductsRequest!, didReceiveResponse response: SKProductsResponse!)
OS X 10.10
To
func productsRequest(_ request: SKProductsRequest, didReceiveResponse response: SKProductsResponse)
OS X 10.7

Declaration
From
class SKProductsResponse : NSObject {
    var products: [AnyObject]! { get }
    var invalidProductIdentifiers: [AnyObject]! { get }
}
To
class SKProductsResponse : NSObject {
    var products: [SKProduct]? { get }
    var invalidProductIdentifiers: [String]? { get }
}

Declaration
From
var invalidProductIdentifiers: [AnyObject]! { get }
To
var invalidProductIdentifiers: [String]? { get }

Declaration
From
var products: [AnyObject]! { get }
To
var products: [SKProduct]? { get }

Declaration
From
class SKReceiptRefreshRequest : SKRequest {
    init!(receiptProperties properties: [NSObject : AnyObject]!)
    var receiptProperties: [NSObject : AnyObject]! { get }
}
To
class SKReceiptRefreshRequest : SKRequest {
    init?(receiptProperties properties: [String : AnyObject])
    var receiptProperties: [String : AnyObject]? { get }
}

Declaration
From
init!(receiptProperties properties: [NSObject : AnyObject]!)
To
init?(receiptProperties properties: [String : AnyObject])

Declaration
From
var receiptProperties: [NSObject : AnyObject]! { get }
To
var receiptProperties: [String : AnyObject]? { get }

Modified SKRequest
Declaration
From
class SKRequest : NSObject {
    unowned(unsafe) var delegate: SKRequestDelegate!
    func cancel()
    func start()
}
To
class SKRequest : NSObject {
    unowned(unsafe) var delegate: SKRequestDelegate?
    func cancel()
    func start()
}

Declaration
From
unowned(unsafe) var delegate: SKRequestDelegate!
To
unowned(unsafe) var delegate: SKRequestDelegate?

Declaration
From
protocol SKRequestDelegate : NSObjectProtocol {
    optional func requestDidFinish(_ request: SKRequest!)
    optional func request(_ request: SKRequest!, didFailWithError error: NSError!)
}
To
protocol SKRequestDelegate : NSObjectProtocol {
    optional func requestDidFinish(_ request: SKRequest)
    optional func request(_ request: SKRequest, didFailWithError error: NSError?)
}

DeclarationIntroduction
From
optional func request(_ request: SKRequest!, didFailWithError error: NSError!)
OS X 10.10
To
optional func request(_ request: SKRequest, didFailWithError error: NSError?)
OS X 10.7

DeclarationIntroduction
From
optional func requestDidFinish(_ request: SKRequest!)
OS X 10.10
To
optional func requestDidFinish(_ request: SKRequest)
OS X 10.7