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
159 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
- Overlapping UICollectionView in storyboard
- Cannot pod spec lint because of undeclared type errors
- Is the transactionReceipt data present in dataWithContentsOfURL?
- UIWebView Screen Fitting Issue
- ZXingObjC encoding issues
- iOS: None of the valid provisioning profiles allowed the specific entitlements
- How to hide "Now playing url" in control center
- CloudKit: Preventing Duplicate Records
- Slow performance on ipad erasing image
- Swift code with multiple NSDateFormatter - optimization
- iOS 8.3 Safari crashes on input type=file
- TTTTimeIntervalFormatter always returns strings in English
- How do I add multiple in app purchases in Swift Spritekit?
- Setup code for xibs in iOS. -awakFromNb:
- iOS Voice Over only reads out the title of any alert views
Related Questions in NSMUTABLEARRAY
- mutating method sent to immutable object' in nsmutablearray
- Why doesn't this simple NSPredicate filter my array
- How to store JSON Dictionary response in NSMutableArray
- Sort an array using NSSortDescriptor without use of any key?
- Why can't I access the elements of my NSMutableArray?
- Overwriting NSMutableArray loaded from NSUserDefaults
- Line of code from Swift to Objective-C
- Can we create n no.of NSMutableArray dynamically?
- How to add UIImage object into NSMutableArray in iOS
- Core Data and a UIActivityViewController
- KVO. ObserveValueForKeyPAth is not called
- Collision Detection with an NSMutable array of Objects
- What sense to copy empty array?
- NSMutableArrays store only 2 objects
- Why can't I create an NSMutableArray of integers?
Related Questions in NSUSERDEFAULTS
- How to use For Loop through keys of NSUserDefault Dictionary
- Save UIPickerView selection to NSUserDefaults swift
- NSUserdefaults not working with NSKeyedArchiver
- Share custom data with today extension by NSUserDefaults
- For storing a growing collection of data records, is NSUserDefaults or CoreData better?
- Open in same view controller as closed on (swift)
- how can i save the high score?
- Overwriting NSMutableArray loaded from NSUserDefaults
- How do I increment and save a int value in Swift?
- APNS get all push notifications
- How to get a NSuser default value in another viewcontroller in swift
- NSUserDefaults not working on Xcode beta with Watch OS2
- NSMutableArrays store only 2 objects
- How can I save the high score in sprite kit using swift?
- Display high score in a new scene with NSUserDefault in swift spriteKit
Related Questions in NSCODING
- IOS Where To Persist Current User from Back-end
- NSUserdefaults not working with NSKeyedArchiver
- Converting CLLocationCoordinate2D to a String that can be stored
- Swift NSCoding with NSValue
- Saving Structs in Swift
- Conforming to NSCoding
- How to fix: Use of undeclared type 'URL' & Use of unresolved identifier 'DispatchQueue' in Swift?
- Encode enum with NSCoding
- Attempt to insert non-property list object when trying to save a custom object in Swift 3
- How to encode a value passed through a delegate using NSCoding
- Conforming Class to NSCoding
- Swift NSCoding - How to read an encoded array
- encoding in Swift 3
- Convert Class Object to NSData Which Does Not Conform to NSCoding
- Swift NSObject subclass get BAD_ACCESS
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 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 :)