Reputation: 827
Having a bit of an issue with using keychain to store login information to my app. It works perfectly fine and will display the information when I go in and out of other apps but once I fully close down the app and try to reopen it and click to bring back up the login information the app crashes. I will attach the code and also the error log. I do understand that using this version of keychain isn't done by most people from my reading online people seem to use alternative keychain scripts but hopefully someone has run into this problem. I have 3 buttons and 2 text fields to test it. One text field for username, one for password then I have a button to sign in which saves the information, a button to view the information then a logout button.
Thanks.
Dec 31 01:58:13 Curtis-iPhone uDropOff 3[18034] : -[__NSCFData rangeOfCharacterFromSet:]: unrecognized selector sent to instance 0x147ed0338 Dec 31 01:58:13 Curtis-iPhone uDropOff 3[18034] : * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFData rangeOfCharacterFromSet:]: unrecognized selector sent to instance 0x147ed0338' * First throw call stack: (0x180eed900 0x18055bf80 0x180ef461c 0x180ef15b8 0x180df568c 0x186529988 0x185c206f4 0x1000c0194 0x185c17e50 0x185c17dcc 0x185bffa88 0x185c176e4 0x185c17314 0x185c0fe30 0x185be04cc 0x185bde794 0x180ea4efc 0x180ea4990 0x180ea2690 0x180dd1680 0x1822e0088 0x185c48d90 0x1000c4980 0x1809728b8) Dec 31 01:58:13 Curtis-iPhone SpringBoard[15499] : HW kbd: Failed to set (null) as keyboard focus Dec 31 01:58:13 Curtis-iPhone com.apple.xpc.launchd[1] (UIKitApplication:uDropOff.uDropOff-3[0x44ca][18034]) : Service exited due to signal: Abort trap: 6 Dec 31 01:58:13 Curtis-iPhone diagnosticd[15528] : unable to find offset 0x809679a4 in shared cache for arch 'arm64' Dec 31 01:58:13 Curtis-iPhone ReportCrash[18035] : platform_thread_get_unique_id matched 6392471 Dec 31 01:58:13 Curtis-iPhone ReportCrash[18035] : Formulating report for corpse[18034] uDropOff 3 Dec 31 01:58:13 Curtis-iPhone ReportCrash[18035] : saved type '109_uDropOff 3' report (5 of max 25) as /var/mobile/Library/Logs/CrashReporter/uDropOff 3_2015-12-31-015813_Curtis-iPhone.ips Dec 31 01:58:13 Curtis-iPhone SpringBoard[15499] : Application 'UIKitApplication:uDropOff.uDropOff-3[0x44ca]' crashed. Dec 31 01:58:13 Curtis-iPhone UserEventAgent[15467] : 20372720635010: id=uDropOff.uDropOff-3 pid=18034, state=0 Dec 31 01:58:23 Curtis-iPhone locationd[15505] : Location icon should now be in state 'Inactive'
- (void)viewDidLoad
{
[super viewDidLoad];
keychain = [[KeychainItemWrapper alloc] initWithIdentifier:@"uDropOffLoginData" accessGroup:nil];
}
- (IBAction)viewkeychain {
if ([[keychain objectForKey:(id)kSecAttrAccount] isEqual: @""])
{
self.username.text = @"nousername";
self.password.text = @"nopassword";
}
else
{
self.username.text = [keychain objectForKey:(id)kSecAttrAccount];
self.password.text = [keychain objectForKey:(id)kSecValueData];
}
}
- (IBAction)logout {
[keychain resetKeychainItem];
}
- (IBAction)signin {
[keychain setObject:[_username text] forKey:(id)kSecAttrAccount];
[keychain setObject:[_password text] forKey:(id)kSecValueData];
}
Upvotes: 0
Views: 1004
Reputation: 827
I have fixed this code myself, by changing kSecValueData to kSecAttrService everything works fine and the crash no longer happens.
Upvotes: 0