Search code examples
iosxcodemethodskeychain

How to use a custom class in a view controller?


Alright I created some custom classes for my project sourced from this tutorial, and I figured out if I want to use this class in my ViewControllerWelcome.m file that I need to first import the class at the top of the file using the following: #import "KeychainHelper.h

Once I've done that, I create a Keychainhelper object in my ViewControllerWelcome.m file with the following KeychainHelper *keychainhelper = [[KeychainHelper alloc]init];

Now I want to check the pin the user has inputted into the textfield to the one stored in the Keychain. The KeychainHelper class has a method + (NSString*)getPasswordForKey:(NSString*)aKey; but I am not sure how to use / implement / send a message to this method in my ViewControllerWelcome.m file.


Solution

  • you should simply be able to do the following:

    NSString *password = [KeychainHelper getPasswordForKey:inputKey]