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 になっています ...
事前に感謝します。