Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Updated to version 1.2

  • Loading branch information...
commit 761dbc150c8ca2e4fb92c8d76713de29768c7d27 1 parent 5f192d2
Nick Lockwood authored
10 Examples/Advanced Example/FXKeychainExample/ViewController.m
@@ -14,7 +14,6 @@ @interface ViewController () <UITextFieldDelegate, UITextViewDelegate>
14 14
15 15 @property (nonatomic, strong) FXKeychain *keychain;
16 16
17   -@property (nonatomic, weak) IBOutlet UITextField *accountField;
18 17 @property (nonatomic, weak) IBOutlet UITextField *serviceField;
19 18 @property (nonatomic, weak) IBOutlet UITextField *accessGroupField;
20 19
@@ -32,8 +31,7 @@ - (void)viewDidLoad
32 31
33 32 //get settings from NSUserDefaults
34 33 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
35   - _accountField.text = [defaults objectForKey:@"account"] ?: @"default";
36   - _serviceField.text = [defaults objectForKey:@"service"] ?: @"default";
  34 + _serviceField.text = [defaults objectForKey:@"service"] ?: [[NSBundle mainBundle] bundleIdentifier];
37 35 _accessGroupField.text = [defaults objectForKey:@"accessGroup"];
38 36 _keyField.text = [defaults objectForKey:@"key"] ?: @"password";
39 37
@@ -45,17 +43,16 @@ - (void)saveSettings
45 43 {
46 44 //preserve settings in NSUserDefaults
47 45 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
48   - [defaults setObject:_accountField.text forKey:@"account"];
49 46 [defaults setObject:_serviceField.text forKey:@"service"];
50 47 [defaults setObject:_accessGroupField.text forKey:@"accessGroup"];
51 48 [defaults setObject:_keyField.text forKey:@"key"];
  49 + [defaults synchronize];
52 50 }
53 51
54 52 - (void)updateKeychainFromFields
55 53 {
56 54 //create keychain
57   - _keychain = [[FXKeychain alloc] initWithAccount:_accountField.text
58   - service:_serviceField.text
  55 + _keychain = [[FXKeychain alloc] initWithService:_serviceField.text
59 56 accessGroup:_accessGroupField.text];
60 57 }
61 58
@@ -94,7 +91,6 @@ - (IBAction)delete
94 91
95 92 - (IBAction)tap
96 93 {
97   - [_accountField resignFirstResponder];
98 94 [_serviceField resignFirstResponder];
99 95 [_accessGroupField resignFirstResponder];
100 96 [_keyField resignFirstResponder];
141 Examples/Advanced Example/FXKeychainExample/en.lproj/ViewController.xib
... ... @@ -1,14 +1,14 @@
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="8.00">
3 3 <data>
4   - <int key="IBDocument.SystemTarget">1536</int>
5   - <string key="IBDocument.SystemVersion">12C3012</string>
6   - <string key="IBDocument.InterfaceBuilderVersion">2844</string>
7   - <string key="IBDocument.AppKitVersion">1187.34</string>
8   - <string key="IBDocument.HIToolboxVersion">625.00</string>
  4 + <int key="IBDocument.SystemTarget">1552</int>
  5 + <string key="IBDocument.SystemVersion">12D78</string>
  6 + <string key="IBDocument.InterfaceBuilderVersion">3084</string>
  7 + <string key="IBDocument.AppKitVersion">1187.37</string>
  8 + <string key="IBDocument.HIToolboxVersion">626.00</string>
9 9 <object class="NSMutableDictionary" key="IBDocument.PluginVersions">
10 10 <string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
11   - <string key="NS.object.0">1930</string>
  11 + <string key="NS.object.0">2083</string>
12 12 </object>
13 13 <array key="IBDocument.IntegratedClassDependencies">
14 14 <string>IBProxyObject</string>
@@ -39,20 +39,20 @@
39 39 <reference key="NSNextResponder"/>
40 40 <int key="NSvFlags">274</int>
41 41 <array class="NSMutableArray" key="NSSubviews">
42   - <object class="IBUILabel" id="35689451">
  42 + <object class="IBUILabel" id="445052618">
43 43 <reference key="NSNextResponder" ref="774585933"/>
44 44 <int key="NSvFlags">292</int>
45   - <string key="NSFrame">{{20, 20}, {62, 21}}</string>
  45 + <string key="NSFrame">{{20, 22}, {57, 21}}</string>
46 46 <reference key="NSSuperview" ref="774585933"/>
47 47 <reference key="NSWindow"/>
48   - <reference key="NSNextKeyView" ref="818338509"/>
  48 + <reference key="NSNextKeyView" ref="1040392897"/>
49 49 <string key="NSReuseIdentifierKey">_NS:9</string>
50 50 <bool key="IBUIOpaque">NO</bool>
51 51 <bool key="IBUIClipsSubviews">YES</bool>
52 52 <int key="IBUIContentMode">7</int>
53 53 <bool key="IBUIUserInteractionEnabled">NO</bool>
54 54 <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
55   - <string key="IBUIText">Account</string>
  55 + <string key="IBUIText">Service</string>
56 56 <object class="NSColor" key="IBUITextColor" id="65806915">
57 57 <int key="NSColorSpace">1</int>
58 58 <bytes key="NSRGB">MCAwIDAAA</bytes>
@@ -64,38 +64,17 @@
64 64 <int key="type">1</int>
65 65 <double key="pointSize">15</double>
66 66 </object>
67   - <object class="NSFont" key="IBUIFont" id="850344025">
  67 + <object class="NSFont" key="IBUIFont" id="76311576">
68 68 <string key="NSName">Helvetica</string>
69 69 <double key="NSSize">15</double>
70 70 <int key="NSfFlags">16</int>
71 71 </object>
72 72 <bool key="IBUIAdjustsFontSizeToFit">NO</bool>
73 73 </object>
74   - <object class="IBUILabel" id="445052618">
75   - <reference key="NSNextResponder" ref="774585933"/>
76   - <int key="NSvFlags">292</int>
77   - <string key="NSFrame">{{20, 63}, {57, 21}}</string>
78   - <reference key="NSSuperview" ref="774585933"/>
79   - <reference key="NSWindow"/>
80   - <reference key="NSNextKeyView" ref="1040392897"/>
81   - <string key="NSReuseIdentifierKey">_NS:9</string>
82   - <bool key="IBUIOpaque">NO</bool>
83   - <bool key="IBUIClipsSubviews">YES</bool>
84   - <int key="IBUIContentMode">7</int>
85   - <bool key="IBUIUserInteractionEnabled">NO</bool>
86   - <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
87   - <string key="IBUIText">Service</string>
88   - <reference key="IBUITextColor" ref="65806915"/>
89   - <nil key="IBUIHighlightedColor"/>
90   - <int key="IBUIBaselineAdjustment">0</int>
91   - <reference key="IBUIFontDescription" ref="685696947"/>
92   - <reference key="IBUIFont" ref="850344025"/>
93   - <bool key="IBUIAdjustsFontSizeToFit">NO</bool>
94   - </object>
95 74 <object class="IBUILabel" id="97260464">
96 75 <reference key="NSNextResponder" ref="774585933"/>
97 76 <int key="NSvFlags">292</int>
98   - <string key="NSFrame">{{20, 109}, {55, 21}}</string>
  77 + <string key="NSFrame">{{20, 68}, {55, 21}}</string>
99 78 <reference key="NSSuperview" ref="774585933"/>
100 79 <reference key="NSWindow"/>
101 80 <reference key="NSNextKeyView" ref="489861085"/>
@@ -110,13 +89,13 @@
110 89 <nil key="IBUIHighlightedColor"/>
111 90 <int key="IBUIBaselineAdjustment">0</int>
112 91 <reference key="IBUIFontDescription" ref="685696947"/>
113   - <reference key="IBUIFont" ref="850344025"/>
  92 + <reference key="IBUIFont" ref="76311576"/>
114 93 <bool key="IBUIAdjustsFontSizeToFit">NO</bool>
115 94 </object>
116 95 <object class="IBUILabel" id="814592518">
117 96 <reference key="NSNextResponder" ref="774585933"/>
118 97 <int key="NSvFlags">292</int>
119   - <string key="NSFrame">{{20, 189}, {30, 21}}</string>
  98 + <string key="NSFrame">{{20, 144}, {30, 21}}</string>
120 99 <reference key="NSSuperview" ref="774585933"/>
121 100 <reference key="NSWindow"/>
122 101 <reference key="NSNextKeyView" ref="370229739"/>
@@ -131,22 +110,22 @@
131 110 <nil key="IBUIHighlightedColor"/>
132 111 <int key="IBUIBaselineAdjustment">0</int>
133 112 <reference key="IBUIFontDescription" ref="685696947"/>
134   - <reference key="IBUIFont" ref="850344025"/>
  113 + <reference key="IBUIFont" ref="76311576"/>
135 114 <bool key="IBUIAdjustsFontSizeToFit">NO</bool>
136 115 </object>
137   - <object class="IBUITextField" id="818338509">
  116 + <object class="IBUITextField" id="1040392897">
138 117 <reference key="NSNextResponder" ref="774585933"/>
139 118 <int key="NSvFlags">290</int>
140   - <string key="NSFrame">{{90, 17}, {210, 30}}</string>
  119 + <string key="NSFrame">{{90, 19}, {210, 30}}</string>
141 120 <reference key="NSSuperview" ref="774585933"/>
142 121 <reference key="NSWindow"/>
143   - <reference key="NSNextKeyView" ref="445052618"/>
  122 + <reference key="NSNextKeyView" ref="97260464"/>
144 123 <string key="NSReuseIdentifierKey">_NS:9</string>
145 124 <bool key="IBUIOpaque">NO</bool>
146 125 <bool key="IBUIClipsSubviews">YES</bool>
147 126 <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
148 127 <int key="IBUIContentVerticalAlignment">0</int>
149   - <string key="IBUIText">default</string>
  128 + <string key="IBUIText"/>
150 129 <int key="IBUIBorderStyle">3</int>
151 130 <object class="NSColor" key="IBUITextColor">
152 131 <int key="NSColorSpace">3</int>
@@ -164,43 +143,16 @@
164 143 <int key="type">1</int>
165 144 <double key="pointSize">14</double>
166 145 </object>
167   - <object class="NSFont" key="IBUIFont" id="520452647">
  146 + <object class="NSFont" key="IBUIFont" id="104901708">
168 147 <string key="NSName">Helvetica</string>
169 148 <double key="NSSize">14</double>
170 149 <int key="NSfFlags">16</int>
171 150 </object>
172 151 </object>
173   - <object class="IBUITextField" id="1040392897">
174   - <reference key="NSNextResponder" ref="774585933"/>
175   - <int key="NSvFlags">290</int>
176   - <string key="NSFrame">{{90, 60}, {210, 30}}</string>
177   - <reference key="NSSuperview" ref="774585933"/>
178   - <reference key="NSWindow"/>
179   - <reference key="NSNextKeyView" ref="97260464"/>
180   - <string key="NSReuseIdentifierKey">_NS:9</string>
181   - <bool key="IBUIOpaque">NO</bool>
182   - <bool key="IBUIClipsSubviews">YES</bool>
183   - <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
184   - <int key="IBUIContentVerticalAlignment">0</int>
185   - <string key="IBUIText">default</string>
186   - <int key="IBUIBorderStyle">3</int>
187   - <object class="NSColor" key="IBUITextColor">
188   - <int key="NSColorSpace">3</int>
189   - <bytes key="NSWhite">MAA</bytes>
190   - <reference key="NSCustomColorSpace" ref="124487435"/>
191   - </object>
192   - <bool key="IBUIAdjustsFontSizeToFit">YES</bool>
193   - <float key="IBUIMinimumFontSize">17</float>
194   - <object class="IBUITextInputTraits" key="IBUITextInputTraits">
195   - <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
196   - </object>
197   - <reference key="IBUIFontDescription" ref="831298535"/>
198   - <reference key="IBUIFont" ref="520452647"/>
199   - </object>
200 152 <object class="IBUITextField" id="489861085">
201 153 <reference key="NSNextResponder" ref="774585933"/>
202 154 <int key="NSvFlags">290</int>
203   - <string key="NSFrame">{{90, 105}, {210, 30}}</string>
  155 + <string key="NSFrame">{{90, 64}, {210, 30}}</string>
204 156 <reference key="NSSuperview" ref="774585933"/>
205 157 <reference key="NSWindow"/>
206 158 <reference key="NSNextKeyView" ref="814592518"/>
@@ -222,12 +174,12 @@
222 174 <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
223 175 </object>
224 176 <reference key="IBUIFontDescription" ref="831298535"/>
225   - <reference key="IBUIFont" ref="520452647"/>
  177 + <reference key="IBUIFont" ref="104901708"/>
226 178 </object>
227 179 <object class="IBUITextField" id="370229739">
228 180 <reference key="NSNextResponder" ref="774585933"/>
229 181 <int key="NSvFlags">290</int>
230   - <string key="NSFrame">{{90, 185}, {210, 30}}</string>
  182 + <string key="NSFrame">{{90, 140}, {210, 30}}</string>
231 183 <reference key="NSSuperview" ref="774585933"/>
232 184 <reference key="NSWindow"/>
233 185 <reference key="NSNextKeyView" ref="496754924"/>
@@ -249,12 +201,12 @@
249 201 <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
250 202 </object>
251 203 <reference key="IBUIFontDescription" ref="831298535"/>
252   - <reference key="IBUIFont" ref="520452647"/>
  204 + <reference key="IBUIFont" ref="104901708"/>
253 205 </object>
254 206 <object class="IBUILabel" id="496754924">
255 207 <reference key="NSNextResponder" ref="774585933"/>
256 208 <int key="NSvFlags">292</int>
257   - <string key="NSFrame">{{20, 230}, {36, 21}}</string>
  209 + <string key="NSFrame">{{20, 185}, {36, 21}}</string>
258 210 <reference key="NSSuperview" ref="774585933"/>
259 211 <reference key="NSWindow"/>
260 212 <reference key="NSNextKeyView" ref="916830202"/>
@@ -269,13 +221,13 @@
269 221 <nil key="IBUIHighlightedColor"/>
270 222 <int key="IBUIBaselineAdjustment">0</int>
271 223 <reference key="IBUIFontDescription" ref="685696947"/>
272   - <reference key="IBUIFont" ref="850344025"/>
  224 + <reference key="IBUIFont" ref="76311576"/>
273 225 <bool key="IBUIAdjustsFontSizeToFit">NO</bool>
274 226 </object>
275 227 <object class="IBUITextView" id="916830202">
276 228 <reference key="NSNextResponder" ref="774585933"/>
277 229 <int key="NSvFlags">274</int>
278   - <string key="NSFrame">{{90, 230}, {210, 152}}</string>
  230 + <string key="NSFrame">{{90, 185}, {210, 197}}</string>
279 231 <reference key="NSSuperview" ref="774585933"/>
280 232 <reference key="NSWindow"/>
281 233 <reference key="NSNextKeyView" ref="955183396"/>
@@ -293,7 +245,7 @@
293 245 <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
294 246 </object>
295 247 <reference key="IBUIFontDescription" ref="831298535"/>
296   - <reference key="IBUIFont" ref="520452647"/>
  248 + <reference key="IBUIFont" ref="104901708"/>
297 249 </object>
298 250 <object class="IBUIButton" id="955183396">
299 251 <reference key="NSNextResponder" ref="774585933"/>
@@ -360,7 +312,6 @@
360 312 <string key="NSFrame">{{220, 397}, {80, 44}}</string>
361 313 <reference key="NSSuperview" ref="774585933"/>
362 314 <reference key="NSWindow"/>
363   - <reference key="NSNextKeyView"/>
364 315 <string key="NSReuseIdentifierKey">_NS:9</string>
365 316 <bool key="IBUIOpaque">NO</bool>
366 317 <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
@@ -381,7 +332,7 @@
381 332 <string key="NSFrame">{{0, 20}, {320, 460}}</string>
382 333 <reference key="NSSuperview"/>
383 334 <reference key="NSWindow"/>
384   - <reference key="NSNextKeyView" ref="35689451"/>
  335 + <reference key="NSNextKeyView"/>
385 336 <object class="NSColor" key="IBUIBackgroundColor">
386 337 <int key="NSColorSpace">3</int>
387 338 <bytes key="NSWhite">MC43NQA</bytes>
@@ -423,14 +374,6 @@
423 374 </object>
424 375 <object class="IBConnectionRecord">
425 376 <object class="IBCocoaTouchOutletConnection" key="connection">
426   - <string key="label">accountField</string>
427   - <reference key="source" ref="372490531"/>
428   - <reference key="destination" ref="818338509"/>
429   - </object>
430   - <int key="connectionID">129</int>
431   - </object>
432   - <object class="IBConnectionRecord">
433   - <object class="IBCocoaTouchOutletConnection" key="connection">
434 377 <string key="label">serviceField</string>
435 378 <reference key="source" ref="372490531"/>
436 379 <reference key="destination" ref="1040392897"/>
@@ -474,14 +417,6 @@
474 417 <object class="IBConnectionRecord">
475 418 <object class="IBCocoaTouchOutletConnection" key="connection">
476 419 <string key="label">delegate</string>
477   - <reference key="source" ref="818338509"/>
478   - <reference key="destination" ref="372490531"/>
479   - </object>
480   - <int key="connectionID">138</int>
481   - </object>
482   - <object class="IBConnectionRecord">
483   - <object class="IBCocoaTouchOutletConnection" key="connection">
484   - <string key="label">delegate</string>
485 420 <reference key="source" ref="1040392897"/>
486 421 <reference key="destination" ref="372490531"/>
487 422 </object>
@@ -570,10 +505,8 @@
570 505 <int key="objectID">6</int>
571 506 <reference key="object" ref="774585933"/>
572 507 <array class="NSMutableArray" key="children">
573   - <reference ref="35689451"/>
574 508 <reference ref="445052618"/>
575 509 <reference ref="97260464"/>
576   - <reference ref="818338509"/>
577 510 <reference ref="1040392897"/>
578 511 <reference ref="489861085"/>
579 512 <reference ref="814592518"/>
@@ -587,12 +520,6 @@
587 520 <reference key="parent" ref="0"/>
588 521 </object>
589 522 <object class="IBObjectRecord">
590   - <int key="objectID">12</int>
591   - <reference key="object" ref="35689451"/>
592   - <array class="NSMutableArray" key="children"/>
593   - <reference key="parent" ref="774585933"/>
594   - </object>
595   - <object class="IBObjectRecord">
596 523 <int key="objectID">15</int>
597 524 <reference key="object" ref="445052618"/>
598 525 <reference key="parent" ref="774585933"/>
@@ -603,12 +530,6 @@
603 530 <reference key="parent" ref="774585933"/>
604 531 </object>
605 532 <object class="IBObjectRecord">
606   - <int key="objectID">21</int>
607   - <reference key="object" ref="818338509"/>
608   - <array class="NSMutableArray" key="children"/>
609   - <reference key="parent" ref="774585933"/>
610   - </object>
611   - <object class="IBObjectRecord">
612 533 <int key="objectID">27</int>
613 534 <reference key="object" ref="1040392897"/>
614 535 <array class="NSMutableArray" key="children"/>
@@ -675,11 +596,9 @@
675 596 <string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
676 597 <string key="103.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
677 598 <string key="109.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
678   - <string key="12.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
679 599 <string key="143.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
680 600 <string key="15.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
681 601 <string key="18.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
682   - <string key="21.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
683 602 <string key="27.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
684 603 <string key="35.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
685 604 <string key="42.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
@@ -740,6 +659,6 @@
740 659 <string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
741 660 <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
742 661 <int key="IBDocument.defaultPropertyAccessControl">3</int>
743   - <string key="IBCocoaTouchPluginVersion">1930</string>
  662 + <string key="IBCocoaTouchPluginVersion">2083</string>
744 663 </data>
745 664 </archive>
6 FXKeychain/FXKeychain.h
... ... @@ -1,7 +1,7 @@
1 1 //
2 2 // FXKeychain.h
3 3 //
4   -// Version 1.1
  4 +// Version 1.2
5 5 //
6 6 // Created by Nick Lockwood on 29/12/2012.
7 7 // Copyright 2012 Charcoal Design
@@ -39,12 +39,10 @@
39 39
40 40 + (instancetype)defaultKeychain;
41 41
42   -@property (nonatomic, copy, readonly) NSString *account;
43 42 @property (nonatomic, copy, readonly) NSString *service;
44 43 @property (nonatomic, copy, readonly) NSString *accessGroup;
45 44
46   -- (id)initWithAccount:(NSString *)account
47   - service:(NSString *)service
  45 +- (id)initWithService:(NSString *)service
48 46 accessGroup:(NSString *)accessGroup;
49 47
50 48 - (BOOL)setObject:(id<NSCoding>)object forKey:(id<NSCopying>)key;
19 FXKeychain/FXKeychain.m
... ... @@ -1,7 +1,7 @@
1 1 //
2 2 // FXKeychain.m
3 3 //
4   -// Version 1.1
  4 +// Version 1.2
5 5 //
6 6 // Created by Nick Lockwood on 29/12/2012.
7 7 // Copyright 2012 Charcoal Design
@@ -48,8 +48,7 @@ + (instancetype)defaultKeychain
48 48 if (!sharedInstance)
49 49 {
50 50 NSString *bundleID = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleIdentifierKey];
51   - sharedInstance = [[FXKeychain alloc] initWithAccount:@"default"
52   - service:bundleID
  51 + sharedInstance = [[FXKeychain alloc] initWithService:bundleID
53 52 accessGroup:nil];
54 53 }
55 54 return sharedInstance;
@@ -57,16 +56,14 @@ + (instancetype)defaultKeychain
57 56
58 57 - (id)init
59 58 {
60   - return [self initWithAccount:nil service:nil accessGroup:nil];
  59 + return [self initWithService:nil accessGroup:nil];
61 60 }
62 61
63   -- (id)initWithAccount:(NSString *)account
64   - service:(NSString *)service
  62 +- (id)initWithService:(NSString *)service
65 63 accessGroup:(NSString *)accessGroup
66 64 {
67 65 if ((self = [super init]))
68 66 {
69   - _account = [account copy];
70 67 _service = [service copy];
71 68 _accessGroup = [accessGroup copy];
72 69 }
@@ -77,10 +74,9 @@ - (BOOL)setObject:(id<NSCoding>)object forKey:(id<NSCopying>)key
77 74 {
78 75 //generate query
79 76 NSMutableDictionary *query = [NSMutableDictionary dictionary];
80   - if ([_account length]) query[(__bridge NSString *)kSecAttrAccount] = _account;
81 77 if ([_service length]) query[(__bridge NSString *)kSecAttrService] = _service;
82 78 query[(__bridge NSString *)kSecClass] = (__bridge id)kSecClassGenericPassword;
83   - query[(__bridge NSString *)kSecAttrGeneric] = key;
  79 + query[(__bridge NSString *)kSecAttrAccount] = key;
84 80
85 81 #if defined __IPHONE_OS_VERSION_MAX_ALLOWED && !TARGET_IPHONE_SIMULATOR
86 82 if ([_accessGroup length]) query[(__bridge NSString *)kSecAttrAccessGroup] = _accessGroup;
@@ -92,7 +88,7 @@ - (BOOL)setObject:(id<NSCoding>)object forKey:(id<NSCopying>)key
92 88 {
93 89 data = [(NSString *)object dataUsingEncoding:NSUTF8StringEncoding];
94 90 }
95   - else
  91 + else if (object)
96 92 {
97 93 data = [NSKeyedArchiver archivedDataWithRootObject:object];
98 94 }
@@ -138,12 +134,11 @@ - (id)objectForKey:(id<NSCopying>)key
138 134 {
139 135 //generate query
140 136 NSMutableDictionary *query = [NSMutableDictionary dictionary];
141   - if ([_account length]) query[(__bridge NSString *)kSecAttrAccount] = _account;
142 137 if ([_service length]) query[(__bridge NSString *)kSecAttrService] = _service;
143 138 query[(__bridge NSString *)kSecClass] = (__bridge id)kSecClassGenericPassword;
144 139 query[(__bridge NSString *)kSecMatchLimit] = (__bridge id)kSecMatchLimitOne;
145 140 query[(__bridge NSString *)kSecReturnData] = (__bridge id)kCFBooleanTrue;
146   - query[(__bridge NSString *)kSecAttrGeneric] = key;
  141 + query[(__bridge NSString *)kSecAttrAccount] = key;
147 142
148 143 #if defined __IPHONE_OS_VERSION_MAX_ALLOWED && !TARGET_IPHONE_SIMULATOR
149 144 if ([_accessGroup length]) query[(__bridge NSString *)kSecAttrAccessGroup] = _accessGroup;
2  LICENCE.md
Source Rendered
... ... @@ -1,6 +1,6 @@
1 1 FXKeychain
2 2
3   -Version 1.1, December 30th, 2012
  3 +Version 1.2, March 21st, 2013
4 4
5 5 Copyright (C) 2012 Charcoal Design
6 6
15 README.md
Source Rendered
@@ -3,7 +3,7 @@ Purpose
3 3
4 4 FXKeychain is a lightweight wrapper around the Apple keychain APIs that exposes the commonly used functionality whilst hiding the horrific complexity and ugly interface of the underlying APIs.
5 5
6   -FXKeychain treats the keychain like a simple dictionary that you can set and get values from. For most purposes you can get by using the defaultKeychain, however it is also possible to create new keychain instances if you wish to namespace your keychain by account/service, or share values between apps using an accessGroup.
  6 +FXKeychain treats the keychain like a simple dictionary that you can set and get values from. For most purposes you can get by using the defaultKeychain, however it is also possible to create new keychain instances if you wish to namespace your keychain by service, or share values between apps using an accessGroup.
7 7
8 8
9 9 Supported iOS & SDK Versions
@@ -34,11 +34,7 @@ Properties
34 34 ------------------
35 35
36 36 FXKeychain has the following properties. They are all immutable once the keychain has been created.
37   -
38   - @property (nonatomic, copy, readonly) NSString *account;
39   -
40   -The account property is used to distinguish between multiple user accounts within the same app. If the app supports multiple users, you might use their username or another user-specific identifer for the account value.
41   -
  37 +
42 38 @property (nonatomic, copy, readonly) NSString *service;
43 39
44 40 The service property is used to distinguish between multiple apps or services on a given device or within the same app. On Mac OS and the iOS simulator, services are shared between apps, so it's a good idea to use something unique for the service, such as the application bundle ID, or the same value as the accessGroup if you wish to share a service between multiple apps.
@@ -53,13 +49,12 @@ Methods
53 49
54 50 + (instancetype)defaultKeychain;
55 51
56   -This method returns a shared default keychain instance, which has the value @"default" for the account and uses the app's bundle ID for the service to avoid namespace collisions with other apps on Mac OS or the iOS simulator.
  52 +This method returns a shared default keychain instance, which uses the app's bundle ID for the service to avoid namespace collisions with other apps on Mac OS or the iOS simulator.
57 53
58   - - (id)initWithAccount:(NSString *)account
59   - service:(NSString *)service
  54 + - (id)initWithService:(NSString *)service
60 55 accessGroup:(NSString *)accessGroup;
61 56
62   -This method creates a new FXKeychain instance with the specified parameters. Each FXKeychain can contain as many key/value pairs as you want, so you may only need a single FXKeychain per application. Each FXKeychain is uniquely identified by the account and service parameters; see the Properties description for how to use these. You can specify nil for the account and/or service values, in which case they will act as "wildcard" selectors and calls to objectForKey: will return the first value found within any account/service pair. The accessGroup parameter is used for setting up shared keychains that can be accessed by multiple different apps; leave this as nil if you do not require that functionality.
  57 +This method creates a new FXKeychain instance with the specified parameters. Each FXKeychain can contain as many key/value pairs as you want, so you may only need a single FXKeychain per application. Each FXKeychain is uniquely identified by the service parameter; see the Properties description for how to use this. You can specify nil for the service, in which case it will act as "wildcard" selector and calls to objectForKey: will return the first value found within any service stored in the keychain. The accessGroup parameter is used for setting up shared keychains that can be accessed by multiple different apps; leave this as nil if you do not require that functionality.
63 58
64 59 - (BOOL)setObject:(id<NSCoding>)object forKey:(id<NSCopying>)key;
65 60 - (BOOL)setObject:(id<NSCoding>)object forKeyedSubscript:(id<NSCopying>)key;
5 RELEASE NOTES.md
Source Rendered
... ... @@ -1,3 +1,8 @@
  1 +Version 1.2
  2 +
  3 +- It is now possible to actually store more than one value per FXKeychain
  4 +- Removed account parameter (it didn't work the way I thought)
  5 +
1 6 Version 1.1
2 7
3 8 - Now uses application bundle ID to namespace the default keychain

0 comments on commit 761dbc1

Please sign in to comment.
Something went wrong with that request. Please try again.