이다

2012-10-11 2 views
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]; 
    } 
} 

전무 내가 ...이다

있는 NSData 객체가 전무하다 얻고 로컬 경로에서 .pkpass 파일을 NSData을 위해 가져 오는 동안

아무도 도와 줄 수 있습니다 미리 감사드립니다.

+1

nslog (@ "% @", nsData)에 대한 nsdata 확인; – Bajaj

답변

1

NSData 개체가 nil 인 경우 사용자의 dataWithContentsOfFile: 호출이 작동하지 않는다는 의미입니다. filePath이 유효한지 확인하십시오. 그렇지 않은 경우 문제가됩니다.

관련 문제