Hello I can not save locally where I have to save an array of strings, I add that this array must be saved when closing the application for iOS and the reopening needs to be recharged, I found thousands of guides online but none are very specific, someone says use NSUserDefaults others say to use NSCoding but in both cases i can not recharge these data can anyone help me?
NsmutableArray don't succeded to save at close of app
161 Views Asked by Filippo At
2
There are 2 best solutions below
0
AudioBubble
On
You can use NSUserDefaults:
[[NSUserDefaults standardUserDefaults] setObject:yourMutableArray forKey:@"Key"];
To get the value from NSMutableArray:
NSMutableArray *array = [NSMutableArray arrayWithArray:[[NSUserDefaults standardUserDefaults] objectForKey:@"Key"]];
Hope this is helpful.
Related Questions in IOS
- URLSession requesting JSON array from server not working
- Incorrect display of LinearGradientBrush in IOS
- Module not found when building flutter app for IOS
- How to share metadata of an audio url file to a WhatsApp conversation with friends
- Occasional crash at NSURLSessionDataTask dataTaskWithRequest:completionHandler:
- Expo Deep linking on iOS is not working (because of Google sign-in?)
- On iOS, the keyboard does not offer a 6-character SMS code
- Hi, there is an error happened when I build my flutter app, after I'm installing firebase packages occurs that error
- The copy/paste functionalities don't work only on iOS in the Flutter app
- Hide LiveActivityIntent Button from Shortcuts App
- While Running Github Actions Pipeline: No Signing Certificate "iOS Development" found: No "iOS Development" signing certificate matching team ID
- Actionable notification api call not working in background
- Accessibility : Full keyboard access with scroll view in swiftui
- There is a problem with the request entity - You are not allowed to create 'iOS' profile with App ID 'XXXX'
- I am getting "binding has not yet been initialized" error when trying to connect firebase with flutter
Related Questions in NSMUTABLEARRAY
- Assign double variable to mutable array
- Array multiplication in Objective-C, for NSArray and NSMutableArray
- How to test for an uninitialized mutable array
- Syntax to access objects in my NSMutableArray
- Reading Character Array from Shared class in KotlinMultiPlatform (KMM)
- Get Contents of Files In Array on iOS
- how can the whole NSMutableArray be filled with the same object(NSString)
- Section not saving moveRowAtIndexPath objective c
- Swift: subclass NSMutableArray
- Adding additional view to front of hierarchy of TableViews
- Do NSArray and NSMutableArray classes take up the same size in memory?
- Merge two NSMutableArray in Swift
- NSMutableDictionary not updating the tableView
- Change value of a particular key in array of dictionaries in SWIFT
- Cannot convert value of type 'NSArray.Element' to expected argument
Related Questions in NSUSERDEFAULTS
- NSUserDefaults resets to wrong 'Webkit' content on iOS simulator 17
- Using Jamf to security write new configuration to managed application
- How to update userdefaults in another viewController once it is saved in a different viewController without overwriting the first one
- Does the UserDefault api guarantee privacy?
- Can NSUserDefaults work across different code bases?
- How to bind @Published variable value to @propertyWrapper in SwiftUI
- iOS 17 - UserDefaults getting cleared on relaunching the app
- Overriding UserDefaults with XCUIApplication.launchArguments ignores all future updates to that key, so how do I test it?
- UserDefault: Is there any solution to add Favorited Movies into UserDefault
- Clear unused UserDefaults key values from app
- Why is my code erroring when I try to store a color to UserDefaults and then save it back to background color?
- Swift/SwiftUI func not reading updated values from variables set in previous func
- How do I print the UserDefaults information Label ? Swift
- Is there a way to use CFBundleShortVersionString to recognize new builds in Testflight?
- NSUserDefault don't access value in a sandbox MacOS app
Related Questions in NSCODING
- Swift NSCoding enum of Hashable
- Swift NSCoding how to decode custom object
- NSCoder fails to decode object a second time if the object was already successfully decoded
- NSKeyedUnarchiver unarchiveTopLevelObjectWithData deprecated - Array loads as nil even though it's in the archive
- How can make Codable of type PhotosPickerItem?
- Serializing a class which doesn't implement NSCoding
- How to unarchive MLMultiArray with NSKeyedUnarchiver?
- UserDefaults Decoder Not Decoding
- How to unarchive object using NSKeyedUnarchiver?
- How to save multiple object in single UserDefaults
- Swift NSKeyedUnarchiver Failing After Converting from String to Data
- Xcode 12.5 NSCoding issue with SpriteKit/GameplayKit
- NSKeyedUnarchiver creates multiple instances of the same object references by others
- Why is NSArray of NSNumber(s) failing to decode?
- NSSecureCoding returns nil for properly saved object
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
To Save SMALL data - NSUserDefaults, NSCoding as suggested by other people or saving in plist also or else create a file in document directory and write the contents of array in that file.
LARGE Data- Save it in database using either sqlite or core data.
Choice depends on the requirement of the application and since you have not given the details of the data like maximum number of strings in the array, everyone can suggest you instead of telling a solution. Hope it helps :)