【发布时间】:2014-07-08 14:31:01
【问题描述】:
我正在尝试获取“内容”的字符串,但是当我执行代码时应用程序崩溃......当我尝试使用 self.content.text = "\(theText)" 它工作但我想编码为 UTF8,因为我使用西里尔字母,然后我回来了这些\U0421\U044a\U0434\U044a\U0440\U0436\U0430\U043d\U0438\U0435 \U043d\U0430 \U043f\U0438\U0449\U043e\U0432\U0430 有谁能解决这个问题吗?
代码如下:
let appDel: AppDelegate = UIApplication.sharedApplication().delegate as AppDelegate
let context: NSManagedObjectContext = appDel.managedObjectContext
let theReq = NSFetchRequest(entityName: "Entity1")
theReq.returnsObjectsAsFaults = false
let myPredicate = NSPredicate(format: "objectId == \"\(contentID)\"")
theReq.predicate = myPredicate
let executed:AnyObject = context.executeFetchRequest(theReq, error: nil) as Array
let theText : AnyObject = executed.valueForKey("content")
self.content.text = theText
【问题讨论】: