nsuserdefaults

NSUserDefaults Settings Bundle Plist

元气小坏坏 提交于 2019-12-31 03:52:01
问题 I have an app that checks for a file upon load from the appDelegate's appDidFinishLoading method using a url value that I supposedly store in the NSUserDefaults Settings Root Plist: NSString *pathStr = [[NSBundle mainBundle] bundlePath]; NSString *settingsBundlePath = [pathStr stringByAppendingPathComponent:@"Settings.bundle"]; NSString *finalPath = [settingsBundlePath stringByAppendingPathComponent:@"Root.plist"]; NSDictionary *settingsDict = [NSDictionary dictionaryWithContentsOfFile

How to save a Array with (Multiple Types) in NSUserDefaults

隐身守侯 提交于 2019-12-31 03:40:51
问题 This is pretty simple but can't seem to find the correct information to solve saving an array like this in User Defaults. It says it's not a property that NSUser Defaults Excepts. Code: var notificationList: [(type: String,imageName: String, text: String, date: String, seen: Bool)] = [(type: "Default",imageName: "ClearPartioned", text: "", date: "", seen: true)] if (UserDefaults.standard.object(forKey: "notificationList")) == nil { // first time launching print("making notification list")

iOS - setObject vs. Synchronize

笑着哭i 提交于 2019-12-30 22:52:34
问题 Newbie question. If I set an object into NSUserDefault do I also need to Synchronize to be sure the object goes back into NSUserDefault database permanently? I guess what I am asking is, is "setobject" placing the object right back into the database permanently or into some temporary storage that needs to be synchronized to ensure permanent storage? For example: //below I place a new copy of a list in NSUserDefaults after adding a row of data userDefaults.setObject(newMutableList, forKey:

NSUserDefaults: Is it possible to get userDefaults from another app?

孤街醉人 提交于 2019-12-30 18:45:32
问题 There are two apps installed on iPhone (myApp and competitorApp).competitorApp is saving user settings with using NSUserDefaults. I know all keys (value forKey) which using competitorApp. Is it possible to get values in myApp from competitorApp? 回答1: In the iOS App Programming Guide, in the Security section you can read: For security reasons, iOS places each app (including its preferences and data) in a sandbox at install time. A sandbox is a set of fine-grained controls that limit the app’s

How to resolve “Initializer for conditional binding must have Optional type, not 'Int'”?

我是研究僧i 提交于 2019-12-30 14:46:10
问题 I've seen examples of how to resolve this error but I can't get it to work in my case. Initializer for conditional binding must have Optional type, not 'Int' Shouldn't employeeCount be optional since it is inferring the right side? static func getEmployeeCount() -> Int { if let employeeCount = UserDefaults.standard.integer(forKey: "employeeCount") { return employeeCount as! Int } return 0 } 回答1: The problem is UserDefaults.standard.integer return Int , not Int? . So you don't need to wrap it

How to resolve “Initializer for conditional binding must have Optional type, not 'Int'”?

人盡茶涼 提交于 2019-12-30 14:45:05
问题 I've seen examples of how to resolve this error but I can't get it to work in my case. Initializer for conditional binding must have Optional type, not 'Int' Shouldn't employeeCount be optional since it is inferring the right side? static func getEmployeeCount() -> Int { if let employeeCount = UserDefaults.standard.integer(forKey: "employeeCount") { return employeeCount as! Int } return 0 } 回答1: The problem is UserDefaults.standard.integer return Int , not Int? . So you don't need to wrap it

See NSUserDefaults file content

本秂侑毒 提交于 2019-12-30 10:39:32
问题 Is there any way I can see the content of NSUserDefaults? I'm able to open the plist file using "pico" from the terminal, but it shows weird characters, I can't actually see the content file content. Is there any way I can open the file in Xcode? Basically, I want to be able to see and edit the content of NSUserDefaults without the need of doing so programmatically, I'd like to do so from the Terminal or from Xcode. Cheers! 回答1: I'm able to open the file using "pico" but it shows weird

How persistent is [NSUserDefaults standardUserDefaults]?

我怕爱的太早我们不能终老 提交于 2019-12-30 06:11:13
问题 I'm using [NSUserDefaults standardUserDefaults] for storing application settings. My questions are: do those settings are removed on app deletion? are they kept after an application update (through the AppStore)? Because I'm using it to store a password and don't want my users to reset them at each update. Also, I'd like that the only way to reset the password would be to remove the app and re-install it. Is NSUserDefault the right choice? Thanks, Jérémy 回答1: Yes, they are removed on app

How persistent is [NSUserDefaults standardUserDefaults]?

∥☆過路亽.° 提交于 2019-12-30 06:11:12
问题 I'm using [NSUserDefaults standardUserDefaults] for storing application settings. My questions are: do those settings are removed on app deletion? are they kept after an application update (through the AppStore)? Because I'm using it to store a password and don't want my users to reset them at each update. Also, I'd like that the only way to reset the password would be to remove the app and re-install it. Is NSUserDefault the right choice? Thanks, Jérémy 回答1: Yes, they are removed on app

Why I can't save WKWebView to [NSUserDefaults standardUserDefaults]?

拟墨画扇 提交于 2019-12-30 03:14:44
问题 NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; [prefs setObject:self.webView forKey:@"webView"]; The code above is made to save a WKWebView object but I'm getting a compiler error: 2014-11-08 14:58:52.561 Restoration[2431:482391] Property list invalid for format: 200 (property lists cannot contain objects of type 'CFType') 2014-11-08 14:58:52.564 Restoration[2431:482391] Attempt to set a non-property-list object > as an NSUserDefaults/CFPreferences value for key webView 2014