Questions tagged [userdefaults]
507 questions
0
votes
1 answer
Saving array of [String: Any] to user default crash occasionally?
I try to save an array of [String: Any] to user default, and for some situations it works, but others do not. I use the following to save to the default:
static func savingQueueToDisk(){
let queueDict = App.delegate?.queue?.map({ (track)…

Kesong Xie
- 1,316
- 3
- 15
- 35
0
votes
0 answers
User defaults for array of objects
Here is my class that I will make an array of and save it:
import Foundation
import UIKit
class Med: NSObject, NSCoding {
var nombre : String!
var dias : Int!
var semanas : Int!
var minutos : Int!
var horas : Int!
var…

Victor Elizalde
- 3
- 2
0
votes
1 answer
How to Handle Encoding a Swift Struct Containing Swift Struct as Property
I have a requirement to persist a preferred Location that has been selected by a user. The Location contains a few properties:
public struct Location {
// MARK: - Properties
public let identifier: Int
public let name: String
…

Nick Kohrn
- 5,779
- 3
- 29
- 49
0
votes
1 answer
Why is my value nil when i try to read from shared group using UserDefaults (watchOS)
Hi i use a shared group to store a value in that i need to read from my watch but because of some reson, the value is nil.
i made a app group in the developer portal and i enabled and checked the app group in the application and watchkit extension…

Remco
- 21
- 1
- 5
0
votes
2 answers
Table View doesn't show Data, why? (Swift 3)
I've made an app using a table view to persist data. The table view shows the elements of an array which is saved through UserDefaults. Since TableViewControllers look kind of ugly, I did it a bit different: I put a TableView into a normal…

Whazzup
- 175
- 2
- 12
0
votes
1 answer
Coufused about using UserDefaults to make administrator ID
I used UserDefaults to make a login Screen.
My question is I need an administrator let Apple's examiner can direct sign in my app without register again. What should I do next? Please help me!Thanks!
Here is my code:
//This is register's code
…

SU William
- 21
- 5
0
votes
2 answers
How to save the state of UITableViewCell accessory checkmark in Swift 3
I have a table view and I would like the user to select only one item from the table view, then I want to add a checkmark to the cell. At the same time, I also want the checkmark on other cells to disappear so the. user can only select one at a…

techcoderx
- 602
- 1
- 7
- 21
0
votes
2 answers
Accessing UserDefaults in Swift from other viewControllers
In my application, I use UserDefaults to store the user's login status (whether they are logged in or not), and their username. It works fine in that when I login, close the app, and open it again my app skips the login page and recognizes that I am…

Kyle Papili
- 419
- 1
- 7
- 16
0
votes
1 answer
Custom Class Unarchive is nil in Cocoa Swift
I am trying to save and retrieve a custom class to UserDefaults in my macOS app. I am getting nil for newData
class countClass: NSObject, NSCoding {
var leftClickCount : Int = 0
init(leftClickCount: Int) {
self.leftClickCount =…

Kashif
- 4,642
- 7
- 44
- 97
0
votes
1 answer
UserDefaults - not saving consistently when using Xcode Simulator
I am learning iOS development and I have stumbled across an issue where UserDefaults doesn't seem to be consistently saving correctly.
When I open the app, it checks to see if a UserDefaults property exists, if so, it does something. Now, if I save…

Michael
- 1,769
- 2
- 12
- 21
0
votes
2 answers
Saving the data of a table view in Swift 3
I'm trying to build a simple to-do list app with Swift 3 and Xcode 8. It includes a text input box, a submit button, and a table, where each cell includes a title and a subtitle that shows the date. So far, all of this has worked.
Currently, I'm…

Eric Phillips
- 487
- 1
- 6
- 20
0
votes
2 answers
How Keep session in Swift 3.0 using UserDefaults.standard?
I have two(2) swift 3.0 files.
Edited:
My goal is to keep the ViewController active/appear after login is success.
And I want to keep LoginVC active when logout button hit.
Everything works fine such as posting and read json…

AlotJai
- 147
- 4
- 18
0
votes
1 answer
Issues with Setting UserDefaults in Swift 3
Apologize if this is a beginner question, but I am having trouble finding a solution online. Most of the help I could find did not solve my problem and were for a previous version of Swift.
I would like to keep a cumulate score of a player in a…

user7299543
- 121
- 2
- 9
0
votes
4 answers
Saving array with UserDefaults
Is this the right way to save array of dictionaries in tableView using UserDefaults in Swift 3?
var arrNotes = [String:String]
func saveNotesArray () {
UserDefaults.standard.set(arrNotes, forKey: "notes")
…

Jovan Milosavljevic
- 57
- 1
- 2
- 7
0
votes
1 answer
Unable to retrieve dictionary data from Userdefaults in Swift 3
Do you guys can bring some light on the use of dictionaries with UserDefaults ?
What I want to get is to pass a certain dictionary from a view controller to another one using UserDefaults.
var dict = [String : AnyObject?]()
dict = ["Name": "Henri",…