This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 44455 - [watchOS] possible missing NSAttributedString methods
Summary: [watchOS] possible missing NSAttributedString methods
Status: VERIFIED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.WatchOS.dll (show other bugs)
Version: XI 10.0 (iOS10)
Hardware: PC Mac OS
: --- normal
Target Milestone: (C9)
Assignee: Rolf Bjarne Kvinge
URL:
Depends on:
Blocks:
 
Reported: 2016-09-17 02:01 UTC by CraigD
Modified: 2016-09-27 19:51 UTC (History)
5 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description CraigD 2016-09-17 02:01:49 UTC
TL;DR should this file (or parts of it) be included in WATCH build??
https://github.com/xamarin/xamarin-macios/blob/cycle8/src/Foundation/NSAttributedString.cs#L29


LONG VERSION

This code worked in the first release of WatchKit support (it is from the [WatchKitCatalog] sample):

```
var attrString = new NSAttributedString ("Ultralight Label", new UIStringAttributes {
    Font = UIFont.SystemFontOfSize (16f, UIFontWeight.UltraLight)
});
ultralightLabel.SetText (attrString);
```

which suggests a constructor `public NSAttributedString (string str, UIStringAttributes attributes)` existed.

However in Cycle 8/watchOS 3 preview, the above code doesn't compile. This suggests the constructor is missing. I'm not sure if it supposed to be there or not, but it appears to have been removed since an earlier version.


WORKAROUND

There is a simple workaround using the `.Dictionary` property:


```
var attr = new UIStringAttributes
{
    Font = UIFont.SystemFontOfSize(16f, UIFontWeight.UltraLight)
};
var attrString = new NSAttributedString("Ultralight Label", attr.Dictionary);
ultralightLabel.SetText(attrString);
```


[WatchKitCatalog](https://github.com/xamarin/ios-samples/blob/master/WatchKit/WatchKitCatalog/WatchkitExtension/LabelDetailController.cs#L19-L22)
Comment 1 Rolf Bjarne Kvinge 2016-09-22 15:30:33 UTC
PR: https://github.com/xamarin/xamarin-macios/pull/880
Comment 2 Sebastien Pouliot 2016-09-22 17:13:36 UTC
Merged in master 02818182f1d26b3c671af59290e9c9b7a9cc0d66
Comment 3 Saurabh 2016-09-27 10:11:58 UTC
I have checked this Issue with latest master build (XS 6.2.0.608, XI 10.1.0.82). I am successfully able to build WatchKitCatalog: https://github.com/xamarin/ios-samples/blob/master/WatchKit/WatchKitCatalog/WatchkitExtension/LabelDetailController.cs#L19-L22 sample after changing deployment target to 3.0

Build output: https://gist.github.com/saurabh360/2b4a5e3a503d6f68b63151cb108abe38

Environment Info and logs: https://gist.github.com/saurabh360/2a5d19a6be564ee504162589eb946a8b

I will verify this Issue once fix will be merged into C9.
Comment 4 Manish Sinha 2016-09-27 19:51:26 UTC
Verifying C9 bugs in master is sufficient till C9 branches are made available.

Marking as verified

Note You need to log in before you can comment on or make changes to this bug.