Skip to content

Commit

Permalink
Merge pull request #31 from AgileBits/update-readme-source-code
Browse files Browse the repository at this point in the history
Minor code and readme improvements.
  • Loading branch information
MrRooni committed Aug 1, 2014
2 parents 4b65008 + 860f26e commit 0ada237
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,23 @@ - (IBAction)saveLoginTo1Password:(id)sender {
AppExtensionGeneratedPasswordMinLengthKey: @(6),
AppExtensionGeneratedPasswordMaxLengthKey: @(50)
};

__weak typeof (self) miniMe = self;

[[OnePasswordExtension sharedExtension] storeLoginForURLString:@"https://www.acme.com" loginDetails:newLoginDetails passwordGenerationOptions:passwordGenerationOptions forViewController:self completion:^(NSDictionary *loginDict, NSError *error) {

if (!loginDict) {
NSLog(@"Error invoking 1Password App Extension for generate password: %@", error);
NSLog(@"Failed to use 1Password App Extension to save a new Login: %@", error);
return;
}

__strong typeof(self) strongMe = miniMe;

strongMe.firstnameTextField.text = loginDict[AppExtensionReturnedFieldsKey][@"firstname"] ? : @"";
strongMe.lastnameTextField.text = loginDict[AppExtensionReturnedFieldsKey][@"lastname"] ? : @""
strongMe.usernameTextField.text = loginDict[AppExtensionUsernameKey] ? : @"";
strongMe.passwordTextField.text = loginDict[AppExtensionPasswordKey] ? : @"";
strongMe.firstnameTextField.text = loginDict[AppExtensionReturnedFieldsKey][@"firstname"] ? : @"";
strongMe.lastnameTextField.text = loginDict[AppExtensionReturnedFieldsKey][@"lastname"] ? : @""
// retrieve any additional fields that were passed in newLoginDetails dictionary
}];
}

Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,19 @@ Adding 1Password to your registration screen is very similar to adding 1Password
__weak typeof (self) miniMe = self;

[[OnePasswordExtension sharedExtension] storeLoginForURLString:@"https://www.acme.com" loginDetails:newLoginDetails passwordGenerationOptions:passwordGenerationOptions forViewController:self completion:^(NSDictionary *loginDict, NSError *error) {

if (!loginDict) {
NSLog(@"Error invoking 1Password App Extension for generate password: %@", error);
NSLog(@"Failed to use 1Password App Extension to save a new Login: %@", error);
return;
}

__strong typeof(self) strongMe = miniMe;
strongMe.usernameTextField.text = loginDict[AppExtensionUsernameKey] ? : strongMe.usernameTextField.text;
strongMe.passwordTextField.text = loginDict[AppExtensionPasswordKey] ? : strongMe.passwordTextField.text;

strongMe.usernameTextField.text = loginDict[AppExtensionUsernameKey] ? : @"";
strongMe.passwordTextField.text = loginDict[AppExtensionPasswordKey] ? : @"";
strongMe.firstnameTextField.text = loginDict[AppExtensionReturnedFieldsKey][@"firstname"] ? : @"";
strongMe.lastnameTextField.text = loginDict[AppExtensionReturnedFieldsKey][@"lastname"] ? : @""
// retrieve any additional fields that were passed in newLoginDetails dictionary
}];
}
```
Expand Down

0 comments on commit 0ada237

Please sign in to comment.