nsuserdefaults

Is there any way to clear all data stored from the installation of app?

末鹿安然 提交于 2019-12-07 12:15:00
问题 I have an iOS app which stores data in NSUserDefults and many other data is set in cache as a result of web view load, social media signing etc. I want to remove all the data from cache created by the app. Is there any way to do this programmatically in iOS? 回答1: Try NSString *appDomain = [[NSBundle mainBundle] bundleIdentifier]; [[NSUserDefaults standardUserDefaults] removePersistentDomainForName:appDomain]; or [[NSUserDefaults standardUserDefaults] setPersistentDomain:[NSDictionary

What is the best way to secure user's data saved locally in app and how to test security level?

江枫思渺然 提交于 2019-12-07 11:12:48
问题 After the recent attack on App Store I was thinking is the security meaures implemented in app for the user data security are enough? I know there is no guaranteed way to prevent attacks to your app’s data and logic but still we can frustrate attackers by implementing some kind of security .I am looking for the answers for the following questions. is NSUserDefault is secure? is Keychain Access is secure? Which is the better approach NSUserDefault or Keychain Access or any other recommended?

“Expected Declaration” Error in Swift in userDefaults

房东的猫 提交于 2019-12-07 10:59:03
问题 I am trying to save the placeHolderValue in NSUserDefaults, but I am getting an expected declaration error in the third line. let placeHolderValue = 1000 var userDefaults = NSUserDefaults.standardUserDefaults() userDefaults.setValue(placeHolderValue, forKey: "placeholder") userDefaults.synchronize() I've looked everywhere and can't find someone with a similar problem. What am I doing wrong? Thanks! 回答1: I think I didn't have the code above within a function. Once I placed it inside a function

cloudkit: how to access main user's attributes?

流过昼夜 提交于 2019-12-07 03:49:27
I am trying to make an app in which every user would have a personal avatar, a nickname and so on. I don't know how to access the user's account on cloudkit. My solution would be to retrieve user's AppleID, query Cloudkit and modify the user's attribute... But I guess there should be a better way to do it. Isn't their something like NSUserDefault but for cloudkit? You first have to find out what the current loged in userId is. You can do that by executing the fetchUserRecordIDWithCompletionHandler method on the container. Then you can get more (currently only first and last name) information

iOS - Not able to store NSDate into NSUserDefaults

久未见 提交于 2019-12-07 02:50:48
问题 In my application, i want to store the date at which the app is started for the first time. I'm using following code in application:didFinishLaunchingWithOptions method NSDate* today = [NSDate date]; [[NSUserDefaults standardUserDefaults] registerDefaults: @{@"CONSCIENCE_START_DATE" : today}]; NSLog(@"%@", [[NSUserDefaults standardUserDefaults] objectForKey:@"CONSCIENCE_START_DATE"]); But every time when i start the application, its printing the time at which the app is starting. Its not

Save accessory checkmarks on uitableview when users loads view multiple times

拜拜、爱过 提交于 2019-12-07 01:27:16
问题 So I've implemented a UIViewController with a tableview, and basically it loads as a set of "filters" for my uicollectionview. Now, when I click on the checkmarks in my tableview, it "filters" my cells accordingly, but now when I reload the view again I want to display the most recent "checkmarks" I've used, or "filters." I have seen this being implemented with NSUserDefaults, but I have not been able to successfully implement this. If anyone could help me, that will be greatly appreciated.

Clicking on Like all the view should show like objective C

徘徊边缘 提交于 2019-12-07 01:02:28
When I select Throwback -> Description occurs if I click on like button the like button changes to unlike and " like count=1099" increases. If I press back I want this unlike to be displayed next to Throwback let say in a label and again select Throwback button should display unlike and like Count should be 1100. please Help how can i achieve this ? //DetailOfUser.m #impot"DetailsOfStories.h" @interface DetailOfUser ()<UITableViewDelegate,UITableViewDataSource> { NSMutableArray *arrayAboutList; DetailsOfStories *viewController; } - (UITableViewCell *)tableView:(UITableView *)theTableView

Using NSUserDefaults to add a 24hour countdown timer in SWIFT

馋奶兔 提交于 2019-12-06 21:16:33
I am trying to add a timer for when a user clicks a button it starts a timer for 24 hours and disables the button for the next 24 hours. After that it is enabled again. There is a few answers out there for things similar but not 100% useful for doing it in SWIFT. The main problem I am having is that I want this to be specific for each user. So 24 hours for every click on that one user. So for example: If I 'like' something then you want be able to 'like' that particular thing again for 24 hours but can still 'like' a different thing? Thanks You can do it by setting the actual date + 1 day and

NSUserDefaults and iOS framework / library

眉间皱痕 提交于 2019-12-06 20:58:17
问题 I have recently been building an app using [NSUserDefaults standartdUserDefaults] to store locally various information (regarding the session, user preferences, etc). Now I am exporting a subpart of my project as an iOS framework (the goal is to make a SDK). I am generating a MyKit.framework and MyKit.bundle to be imported in third party apps (the bundle contains Storyboards, Localizable.strings and .xcassets). For the moment, I made sure that resources used by MyKit.framework are loaded from

Shared UserDefaults between app and extension not working correctly

浪子不回头ぞ 提交于 2019-12-06 17:10:57
问题 So I've been looking around and following all the steps to setup shared UserDefaults correctly but I should be missing something. I have App Groups capability activated on both my app and my extension. Both use the same suite name ( "group.TestSharedPreferences" ) and I write this way: struct Preferences { static let shared = UserDefaults(suiteName: "group.TestSharedPreferences")! } On viewDidLoad : Preferences.shared.set(1, forKey: "INT") And to read: Preferences.shared.integer(forKey: "INT"