Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
I'm trying to use iCloud to save my app preferences to be shared across devices. I'm using the following code:
When I run the method above an exception is thrown and this occurs on random items in my NSUserDefaults...
Objective-C exception thrown. Name: NSUnknownKeyException Reason: [<NSUbiquitousKeyValueStore 0xaa1380> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key WebKitWebSecurityEnabled.
Exception: Objective-C exception thrown. Name: NSUnknownKeyException Reason: [<NSUbiquitousKeyValueStore 0xaa1380> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key WebKitWebSecurityEnabled.::: at MonoTouch.Foundation.NSObject.SetValueForKey (MonoTouch.Foundation.NSObject value, MonoTouch.Foundation.NSString key) [0x00000] in <filename unknown>:0
at MyApp.MySettings.SaveToCloud () [0x00000] in <filename unknown>:0
I'm not sure if there is a problem in MonoTouch and the bindings that need to be addressed or if it's something I'm doing wrong. These particular properties I'm seeing are BOOL settings in NSUserDefaults.StandardUserDefaults
Can you include settings that cause this crash?
I tried this, but it works for me:
NSUserDefaults.StandardUserDefaults ["WebKitWebSecurityEnabled"] = NSObject.FromObject (true);
I'm not at the office right now but trying adding a BOOL to NSUserDefaults such as:
Now try the iCloud SetDictionary and see if you get an error. Each time I did this, by the way, the error would be on a different user default. It was never the same key repeated.
I still can't reproduce any errors, and I've tried on both an iOS 5.1 device (iPad3) and in the simulator.
Maybe the StandardUserDefaults needs to contain more values for this to happen? Does your code from comment #4 fail if you put it in a new project too?
After some sleep...the item in the error I reported above "WebKitWebSecurityEnabled" is not in my NSUserDefaults.StandardUserDefaults - i.e. it's not something I'm setting so I have no idea where this is coming from! I would think NSUserDefaults.StandardUserDefaults would be things I set to be saved. So maybe this is out of my hands.
Note: I did some searching on WebKitWebSecurityEnabled and it appears that maybe since I have in-app purchasing (StoreKit) integrated these settings are getting added external to my settings and hence being added to iCloud in my attempts. I probably need a better way to isolate out just my settings and not everything else being put into the StandardUserDefaults that I'm not aware of.