2
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];
 }
}

While fetching for NSData from .pkpass file from the local path i am getting the NSData object is nil ...

can anyone help me thanks in advance.

PassKit
12.6k5 gold badges60 silver badges78 bronze badges
asked Oct 11, 2012 at 13:19
1
  • 1
    check nsdata for nslog(@"%@" , nsData); Commented Oct 11, 2012 at 13:22

1 Answer 1

1

If your NSData object is nil it means your dataWithContentsOfFile: call didn't work. Check that your filePath is valid - if it isn't, that's your problem.

answered Oct 11, 2012 at 13:22
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.