2015-06-07 194 views
1

我正在使用NSBatchUpdateRequest來更新我的核心數據內容。我使用下面的代碼:NSBatchUpdateRequest將字符串轉換爲unicode

NSBatchUpdateRequest *req = [[NSBatchUpdateRequest alloc]initWithEntityName:@"Mostvisited"]; 
    req.propertiesToUpdate = @{@"newsCategory":self.newsCategory,@"newsCommentsCount":self.newsCommentsCount,@"newsDate":self.newsJalaliDate,@"newsID":self.newsID,@"newsLead":self.newsLead,@"newsPhotoLink":self.newsPhotoLarge,@"newsTitle":arr,@"newsType":self.newsType,@"timeStamp":[NSDate date] 
           }; 

    req.resultType = NSUpdatedObjectIDsResultType; 
    NSBatchUpdateResult *result = (NSBatchUpdateResult *)[context executeRequest:req error:nil]; 
    NSLog(@"objects update:%@",result.result); 

所有的更新傳遞的對象是包含阿拉伯語NSStringNSArray。令人驚訝的是,當我在更新後獲取核心數據的內容時,我得到的是Unicode字符串不是阿拉伯數字。

回答

0

字符串默認是Unicode,如果你想讓它們成爲阿拉伯語,你可能需要使用CFStringTransform來轉換它們。有一篇很好的文章詳細說明了NSHipster如何實現這一點。

從本質上講,它的這一呼籲:

CFStringTransform(mutableString, nil, kCFStringTransformToLatin, Boolean(0)) 

更多信息: CFStringTransform

相關問題