NSString *filePath = [[[NSBundle mainBundle] resourcePath]stringByAppendingPathComponent:@"freehugcoupon.pkpass"];
NSLog(@"Filepath = [%@]",filePath);
NSData *data = [NSData dataWithContentsOfFile:filePath];
NSError *error;
if (data != nil) {
PKPass *pass = [[PKPass alloc] initWithData:data error:&error];
NSLog(@"Error = [%@]",[error localizedDescription]);
if([passLib containsPass:pass]) {
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Pass Exists" message:@"The pass you are trying to add to Passbook is already present." delegate:nil cancelButtonTitle:@"OK"otherButtonTitles:nil];
[alertView show];
[alertView release];
} else {
PKAddPassesViewController *vc = [[PKAddPassesViewController alloc] initWithPass:pass];
vc.delegate = self;
[self presentViewController:vc animated:YES completion:nil];
[vc release];
[pass release];
}
}
在从本地路径的 .pkpass 文件中获取 NSData 时,我得到的 NSData 对象是 nil ...
任何人都可以帮助我提前谢谢。