Asked  7 Months ago    Answers:  5   Viewed   40 times

I have a login-screen in my iOS app. The username and password will be saved in the NSUserDefaults and be loaded into the login-screen again when you enter the app again (of course, NSUserDefaults are permanent).

Now, the user have the possibility to disable the username/password saving feature.

So the NSUserDefaults will be cleared then.

But In my app I need this username/password for database queries for the user. So: Where to store the data except NSUserDefaults? (This place can / should be deleted when the user quit the app or logout).

 Answers

76

You should always use Keychain to store usernames and passwords, and since it's stored securely and only accessible to your app, there is no need to delete it when app quits (if that was your concern).

Apple provides sample code that stores, reads and deletes keychain items and here is how to use the keychain wrapper class from that sample which greatly simplifies using Keychain.

Include Security.framework (in Xcode 3 right-click on frameworks folder and add existing framework. In Xcode 4 select your project, then select target, go to Build Phases tab and click + under Link Binary With Files) and KeychainItemWrapper .h & .m files into your project, #import the .h file wherever you need to use keychain and then create an instance of this class:

KeychainItemWrapper *keychainItem = [[KeychainItemWrapper alloc] initWithIdentifier:@"YourAppLogin" accessGroup:nil];

(YourAppLogin can be anything you chose to call your Keychain item and you can have multiple items if required)

Then you can set the username and password using:

[keychainItem setObject:@"password you are saving" forKey:kSecValueData];
[keychainItem setObject:@"username you are saving" forKey:kSecAttrAccount];

Get them using:

NSString *password = [keychainItem objectForKey:kSecValueData];
NSString *username = [keychainItem objectForKey:kSecAttrAccount];

Or delete them using:

[keychainItem resetKeychainItem];
Tuesday, June 1, 2021
 
oroshnivskyy
answered 7 Months ago
86

NSUserDefaults is quite easy to use and stores one value per key only. But apparently, it is not a very secure method, as there is no encryption.

But the Keychain is secure, though it is a bit hard to code. You can refer these link to use keychain access.

http://log.scifihifi.com/post/55837387/simple-iphone-keychain-code

you can also use this library deviced by Simon

https://github.com/goosoftware/GSKeychain

I hope it helps you!!

Saturday, June 26, 2021
 
pop
answered 6 Months ago
pop
63

Step 1 - download your developer certificate and drop in into your DEFAULT keychain

step 2 - download apple WWDRCA certificate and drop into the same keychain.

step 3 - CHECK if there is a private key along with your certificate. (you should be able to see tiny triangle beside your certificate. Click on it to see if your private key is present or not)

step 4 - download the provisioning profile from the developer portal and drop into your xcode.

Try to do these things first. If you still get a error, then delete the extra apple certificates in your keychain and try the process once again.. it will do the trick...

Wednesday, July 28, 2021
 
kmunky
answered 5 Months ago
91

These steps can be followed on the device. Founded at this link.

  1. Run the app from Xcode to install it on your device and then stop it from Xcode.
  2. Force quit the app from the app switcher UI on the device.
  3. Navigate to the scheme for the project in Xcode. Under the Run section's Info tab, there is a radio button for "Wait for executable to be launched". Make sure this is checked instead of the "Automatically" option.
  4. Run the app from Xcode. It will not open on the device, but the debugger will wait for it to open and then it will attach to it.

On the simulator as suggested by Marc-Alexandre Bérubé.

  1. Run your app on the simulator.
  2. Force quit the app on the simulator. Press cmd+shift+(hit h twice). Swipe the app up.
  3. Open your terminal and enter this xcrun simctl openurl booted http://yourdomain/path.
Sunday, August 8, 2021
 
xrock
answered 4 Months ago
79

This is not possible. Access to the camera is only possible via UIImagePickerController or through AVFramework, and neither of these provide this functionality.

AVFramework gives you the data stream from the camera, and you have to handle that yourself. Unless you want to implement your own panoramic feature, this isn't appropriate.

Whilst there are settings to adjust flash, video/image and rear/front in UIImagePickerController, there are none to enable the native panoramic feature.

In a similar vain to HDR photographs, Panoramic capture is only available within the Camera app.

Tuesday, August 10, 2021
 
PeteT
answered 4 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :
 
Share