Welcome to the documentation page for the EasyStash CocoaPod! EasyStash is a powerful library that provides an intuitive and easy-to-use interface for managing persistent storage in your iOS applications. Whether you are caching data, storing user preferences, or managing complex data structures, EasyStash has got you covered.
Getting Started
To start using EasyStash in your iOS application, follow the steps below:
- Install EasyStash as a dependency via CocoaPods. Add the following line to your Podfile:
pod 'EasyStash'
- Run the command
pod install
in the terminal to install EasyStash. - Import the EasyStash module in your Swift file(s):
import EasyStash
or Objective-C file(s):
#import <EasyStash/EasyStash.h>
Functionality
Storing Data
EasyStash provides a simple API for storing data persistently in your application. You have the following options:
-
Store: This method allows you to store a value associated with a key. The value can be of any type that conforms to the
Codable
protocol.// Swift EasyStash.store(value, forKey: "yourKey") // Objective-C [EasyStash store:value forKey:@"yourKey"];
-
Store Array: This method allows you to store an array of values associated with a key.
// Swift EasyStash.storeArray([value1, value2], forKey: "yourKey") // Objective-C [EasyStash storeArray:@[value1, value2] forKey:@"yourKey"];
-
Store Dictionary: This method allows you to store a dictionary of values associated with a key.
// Swift EasyStash.storeDictionary(["key1": value1, "key2": value2], forKey: "yourKey") // Objective-C [EasyStash storeDictionary:@{@"key1": value1, @"key2": value2} forKey:@"yourKey"];
Retrieving Data
EasyStash makes it easy to retrieve stored data using the provided methods:
-
Retrieve: This method allows you to retrieve a value associated with a key.
// Swift if let value = EasyStash.retrieve(forKey: "yourKey") as? YourValueType { // Use the retrieved value } // Objective-C YourValueType *value = [EasyStash retrieveForKey:@"yourKey"]; if (value) { // Use the retrieved value }
-
Retrieve Array: This method allows you to retrieve an array of values associated with a key.
// Swift if let array = EasyStash.retrieveArray(forKey: "yourKey") as? [YourValueType] { // Use the retrieved array of values } // Objective-C NSArray
*array = [EasyStash retrieveArrayForKey:@"yourKey"]; if (array) { // Use the retrieved array of values } -
Retrieve Dictionary: This method allows you to retrieve a dictionary of values associated with a key.
// Swift if let dictionary = EasyStash.retrieveDictionary(forKey: "yourKey") as? [String: YourValueType] { // Use the retrieved dictionary of values } // Objective-C NSDictionary
*dictionary = [EasyStash retrieveDictionaryForKey:@"yourKey"]; if (dictionary) { // Use the retrieved dictionary of values }
Removing Data
EasyStash allows you to easily remove stored data using the methods below:
-
Remove: This method removes the stored value associated with a key.
// Swift EasyStash.remove(forKey: "yourKey") // Objective-C [EasyStash removeForKey:@"yourKey"];
-
Remove All: This method removes all stored values.
// Swift EasyStash.removeAll() // Objective-C [EasyStash removeAll];
Conclusion
Congratulations! You have now learned the basics of using EasyStash to manage persistent storage in your iOS applications. Start integrating EasyStash into your project and enjoy the simplicity and power it brings to your data management needs.