看板 MacDev 關於我們 聯絡資訊
obj-c 新手請問 我有一個 instance variable type 是 id: @interface A : NSObject @property (retain) id item; @end 然後我幫這個 class implement 一個簡單的 description: @implementation A @synthesize item; - (NSString *)description { return [NSString stringWithFormat:@"(%@)", self.item]; } @end 我把一個 NSString assign 給 id 這個 type 的 instance variable 然後我想印 A 這種 object: A *a = [[A alloc] init]; a.item = @"8月"; NSLog(@"%@", a); 印出來的東西變成類似這樣: "(8\U6708)" 請問這是為什麼呢? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.37.145.173 ※ 編輯: ratbert 來自: 114.37.145.173 (11/20 01:17)
YunnnYunnn:月的 11/20 02:47
YunnnYunnn:UTF8編碼是U6708 11/20 02:50
ratbert:我的意思是說, 要怎麼讓他印出中文而不是印出UTF8咧? 11/20 11:11
uranusjr:我剛剛試了一下結果很正常... 11/20 14:22
uranusjr:https://gist.github.com/1379881 出來正常的中文 11/20 14:25
ratbert:urh... 我剛試一下我這個簡化版的 code 結果也是正常... 11/20 17:18
ratbert:我再回頭研究一下原本的 code 11/20 17:19