Код: Выделить всё
let data:NSData = NSData(contentsOfFile:path)!
var error1:NSError?
let pass = PKPass.init(data: data, error: &error1)
if(passLib.containsPass(pass)){
let passArray = passLib.passes()
sharedUtility.sharedInstance.showAlertUIViewController("Pass Exists", message: String(passArray.count) + "The pass you are trying to add to Passbook is already present.", buttonTitle: "OK", controller: self)
}
else{
let vc:PKAddPassesViewController = PKAddPassesViewController(pass: pass) as PKAddPassesViewController
self.presentViewController(vc, animated: true, completion: nil)
}
Код: Выделить всё
let passArray = passLib.passes()
if(passArray.count>0){
let onePass:PKPass = passArray[0]
print(onePass)
sharedUtility.sharedInstance.showAlertUIViewController("Pass Found", message: String(passArray.count) + " Found", buttonTitle: "OK", controller: self)
}
else{
sharedUtility.sharedInstance.showAlertUIViewController("Pass Not Found", message: String(passArray.count) + " Found", buttonTitle: "OK", controller: self)
}
Подробнее здесь: https://stackoverflow.com/questions/394 ... m-passbook
Мобильная версия