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.
Created attachment 10400 [details]
There are various properties in UIKit objects that return a UIStringAttributes object (example: UINavigationBar.TitleTextAttributes). In UIKit these are dictionaries (NSDictionary), which by default are immutable. In the binding they are wrapped with a UIStringAttributes class, which assumes that they are mutable. This can lead to crashes.
To reproduce the issue run the attached project. You will crash on this line:
titleAttribtues.ForegroundColor = UIColor.Red;
The exception is this:
Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[__NSDictionaryI __setObject:forKey:]: unrecognized selector sent to instance 0x7b4984e0
The fix the crash you have to create a mutable version like this:
titleAttribtues = new UIStringAttributes(new NSMutableDictionary(titleAttribtues.Dictionary));
This should be done automatically as needed inside UIStringAttributes.
To be clear, this should be fixed for ALL properties that return a UIStringAttributes object, not just the UINavigationBar.TitleTextAttributes property.
Alex, can you have a look at this?
@Adam Thanks for the report!
Fixed in maccore master d00018dca293b829a000fb91779d75f8f2fb108e
@QA added test ^