trong đoạn mã sau tôi sử dụng CoreData để có được kết quả rõ rệt:Swift CoreData DictionaryResultType đúc
request.propertiesToFetch = NSArray(objects: "docID", "docName")
request.resultType = NSFetchRequestResultType.DictionaryResultType
request.returnsDistinctResults = true
var distinctResults: NSArray = context.executeFetchRequest(request, error: nil)
println(distinctResults)
Đây là sản phẩm của println():
( { docID = 3; docName = "Dr. Goy"; }, { docID = 1; docName = "Dr. Bar"; }, { docID = 0; docName = "Dr. Foo"; }, { docID = 2; docName = "Mr. Baz"; } )
Đây là một Array với Từ điển - Làm thế nào tôi có thể đúc NSArray này thành một từ điển với một vòng lặp for
Nhờ sự giúp đỡ!
Bạn muốn từ điển ở định dạng nào? – Jack
Xin lỗi - Tôi muốn truyền tới Từ điển –
Maxim