Objective c 如何将度符号添加到字符串中?

Objective c 如何将度符号添加到字符串中?,objective-c,cocoa,unicode,Objective C,Cocoa,Unicode,我在用Objective-C写作。 如何将度符号添加到字符串中?我知道它的unicode:00B0和UTF8:C2 B0使用字符串文字:\u00B0。对于Unicode字符,它将始终是“\u”后跟字符代码 NSString *temperature = [NSString stringWithFormat:@"65%@", @"\u00B0"]; 刚刚找到了这个非常有用的答案,但它甚至可以缩写为以下内容(不言自明): 以下是您使用Swift的方式: var temperature = "65\

我在用Objective-C写作。
如何将度符号添加到字符串中?我知道它的unicode:
00B0
和UTF8:
C2 B0
使用字符串文字:
\u00B0
。对于Unicode字符,它将始终是“\u”后跟字符代码

NSString *temperature = [NSString stringWithFormat:@"65%@", @"\u00B0"];

刚刚找到了这个非常有用的答案,但它甚至可以缩写为以下内容(不言自明):


以下是您使用Swift的方式:

var temperature = "65\u{00B0}" // degree symbol

我们如何在IB中做到这一点?@OlcayErtaş:您应该能够将°粘贴到字段中。
var temperature = "65\u{00B0}" // degree symbol
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"80\u00b0c"];
    [attributedString setAttributes:@{NSFontAttributeName : [UIFont fontWithName:@"Helvetica-light" size:40.0]
                                      , NSBaselineOffsetAttributeName : @22} range:NSMakeRange(2, 2)];
    //asign this as a 
examplelabel.attributedtext = attributedString;