title: iOS8 Touch ID & Passcode
body: <p>i using this code in iOS 8 for security and uses touch ID </p>
  
  <pre><code>- (IBAction)authenticateButtonTapped{
  
  
  
  
  
      LAContext *myContext = [[LAContext alloc] init];
      NSError *authError = nil;
      NSString *myLocalizedReasonString = @"Authenticate using your finger\r Scan Your Finger Now";
      if ([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&amp;authError]) {
  
          [myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
                    localizedReason:myLocalizedReasonString
                              reply:^(BOOL succes, NSError *error) {
  
                                  if (succes) {
  
                                      [self showMessage:@"Authentication is successful" withTitle:@"Success"];
                                      NSLog(@"User authenticated");
  
  
  
  
  
                                  } else {
  
                                      switch (error.code) {
                                          case LAErrorAuthenticationFailed:
                                              [self showMessage:@"Authentication is failed" withTitle:@"Error"];
                                              NSLog(@"Authentication Failed");
                                              break;
  
                                          case LAErrorUserCancel:
                                              [self showMessage:@"You clicked on Cancel" withTitle:@"Error"];
                                              NSLog(@"User pressed Cancel button");
                                              break;
  
                                          case LAErrorUserFallback:
                                              [self showMessage:@"You clicked on \"Enter Password\"" withTitle:@"Error"];
                                              NSLog(@"User pressed \"Enter Password\"");
  
                                              [self copyMatchingAsync];
                                              break;
  
                                          default:
                                              [self showMessage:@"Touch ID is not configured" withTitle:@"Error"];
                                              NSLog(@"Touch ID is not configured");
                                              break;
                                      }
  
                                      NSLog(@"Authentication Fails");
                                  }
                              }];
      } else {
          NSLog(@"Can not evaluate Touch ID");
          [self showMessage:@"Can not evaluate TouchID" withTitle:@"Error"];
  
      }
  
  
  
  
  
  
  
  }
  </code></pre>
  
  <p>after for use the passcode system i copy this code from apple example</p>
  
  <pre><code>- (void)copyMatchingAsync
  {
      NSDictionary *query = @{
                              (__bridge id)kSecClass: (__bridge id)kSecClassGenericPassword,
                              (__bridge id)kSecAttrService: @"SampleService",
                              (__bridge id)kSecReturnData: @YES,
                              (__bridge id)kSecUseOperationPrompt: NSLocalizedString(@"AUTHENTICATE_TO_ACCESS_SERVICE_PASSWORD", nil)
                              };
  
      dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
          CFTypeRef dataTypeRef = NULL;
          NSString *msg;
  
          OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)(query), &amp;dataTypeRef);
          if (status == errSecSuccess)
          {
              NSData *resultData = ( __bridge_transfer NSData *)dataTypeRef;
              NSString * result = [[NSString alloc] initWithData:resultData encoding:NSUTF8StringEncoding];
  
              msg = [NSString stringWithFormat:NSLocalizedString(@"RESULT", nil), result];
          } else {
  
          }
  
      });
  }
  
  -(void) showMessage:(NSString*)message withTitle:(NSString *)title
  {
  
      UIAlertController * alert=   [UIAlertController
                                    alertControllerWithTitle:title
                                    message:message
                                    preferredStyle:UIAlertControllerStyleAlert];
  
  
      UIAlertAction* cancel = [UIAlertAction
                               actionWithTitle:@"OK"
                               style:UIAlertActionStyleDefault
                               handler:^(UIAlertAction * action)
                               {
                                   [alert dismissViewControllerAnimated:YES completion:nil];
  
                               }];
  
      [alert addAction:cancel];
      [self presentViewController:alert animated:YES completion:nil];
  }
  </code></pre>
  
  <p>its work great and rapid for fingerprint but the passcode system can't show and dosen't work. and i received  "ERROR_ITEM_NOT_FOUND" = "error item not found";</p>
  
  <p>this apple link <a href="https://developer.apple.com/library/ios/samplecode/KeychainTouchID/Introduction/Intro.html" rel="nofollow">https://developer.apple.com/library/ios/samplecode/KeychainTouchID/Introduction/Intro.html</a></p>
  
  <p>but i can't good understand</p>