nsuserdefaults

Why did happen EXC_BAD_ACCESS and SIGABRT when set integer? [closed]

寵の児 提交于 2019-12-13 09:14:19
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I wrote code. I want to save integer using nsuserdefault. But this code happen EXC_BAD_ACCESS and SIGABRT. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { ... [self desave:[newys integerValue] :[newms integerValue]]; ... } ... - (void)desave:(NSInteger*)year :

Swift UserDefaults get values from array

我与影子孤独终老i 提交于 2019-12-13 08:18:27
问题 I have UserDefaults array like: let userValue = ["name": self.nameLbl.text ?? "", "lastName": self.lastNameLbl.text ?? "", "city": cityLbl.text ?? ""] as! [String : String] var userArray = UserDefaults.standard.array(forKey: "userInfo") as? [[String: String]] ?? [] userArray.append(userValue) UserDefaults.standard.set(userArray, forKey: "userInfo") How can I get key values example to print type [["name": .., "lastName":..,],["name": .., "lastName":..,],["name": .., "lastName":..,]...] If I

NSMutableArray to NSData Conversion using NSUserDefaults [closed]

不问归期 提交于 2019-12-13 07:59:11
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . As code shown below,it does not give me back my mutable array. I have 3 annotations in my mutable array, but once I close my app and open it again, it shows me 0 objects. I don't know why I am getting O objects

UISlider, save status

倖福魔咒の 提交于 2019-12-13 07:45:09
问题 My question is about the UISlider . I managed to implement everything but i don't know how i can save its status. Ive looked everywhere but al the posts are in older versions of swift/xcode. So the question is how do i save its status so that when i go to another view and then come back the status is still the same. Thanks very much! import UIKit class SettingsViewController: UIViewController { var sequeInt = 0 let savedWordLength = NSUserDefaults.standardUserDefaults() override func

Displaying an alert message only ONCE but to reappear again on app launch

不羁岁月 提交于 2019-12-13 06:42:11
问题 I'm trying to figure out a way to get a message to appear on one of my view controllers when that screen controller is selected (this view is NOT the first view on the app, so I can't do it at start-up). I only want it to appear ONCE and not appear again when that view is re-selected; however, I want it to appear again if the app is restarted. So far, I am able to get it to appear once without any problem AND it won't pop up again while using the app, which is what I want as I am often going

Is there any advantage of having atomic property for saving in keychains/userdefaults?

末鹿安然 提交于 2019-12-13 06:16:33
问题 For storing some values in NSUserDefaults / keychains is there any advantage of having atomic or non-atomic properties? 回答1: The difference between "atomic" and "non-atomic" is that atomic requires that all of the data must be successfully written while "non-atomic" means "write as much as possible" (i.e. not necessarily all of it). So for many things (e.g. small bits of data), there's not much of a practical difference between non-atomic or atomic. But for larger blocks of data, then non

iOS UIStepper & NSUserDefaults - How to manage them together and use a double

时间秒杀一切 提交于 2019-12-13 06:03:53
问题 I have the following code. However, the line stepper.value = [NSNumber numberWithDouble:loadNumber]; errors with the error 'Sending NSNumber *__strong to a parameter of incompatible type 'double''. I think the stepper will only accept a double, but am unsure what I am doing wrong to set it. What I need to achieve is the following:- 1) Have a default value set in NSUserDefaults for saveNumber , which will be used until a variation is made by the user. 2) on load or view appearing, use

How to keep a total of how many points have been scored overall

萝らか妹 提交于 2019-12-13 06:02:52
问题 I want to keep a track of how many points have been scored overall in game over as many games as the person plays. For example, if a person plays the game 25 times and scores 100 each time then their total score would be 2500. This is the method I am using to increment the score in the game: let waitScore = SKAction.waitForDuration(1.0) //add score every second let incrementScore = SKAction.runBlock ({ ++self.score self.scoreLabel.text = "\(self.score)"}) //update score label with score self

Remove object of NSUserDefault by tableview cell

牧云@^-^@ 提交于 2019-12-13 05:30:24
问题 I have a list of favorites that are stored in the NSUserDefaults, single favorited are stored by NSDictionary: NSUserDefaults *userPref = [NSUserDefaults standardUserDefaults]; NSMutableDictionary *bookmark = [NSMutableDictionary new]; [bookmark setValue:author.text forKey:@"author"]; [bookmark setValue:book.text forKey:@"book"]; [bookmarks addObject:bookmark]; [userPref setObject:bookmarks forKey:@"bookmarks"]; [userPref synchronize]; Everything is ok, but now I want to delete a single

Swift save an array of strings to NSUserdefaults and reuse for notification.alertbody text

倖福魔咒の 提交于 2019-12-13 04:50:26
问题 i am working on a notification project, see this: Swift notification fire from datePicker The problem is this: i have a variable item = news.titleNews (in ViewController.Swift) that is a list of strings like this: one two three etc.. i am converting this variable to an array like this: myArray = [item] and saving to NSUserDefaults like that: NSUserDefaults.standardUserDefaults().setObject(myArray, forKey:"myArray") NSUserDefaults.standardUserDefaults().synchronize() then in settings.swift if