0
我有一個核心數據對象的奇怪問題。使用核心數據返回空值
我有這樣的對象:
2012-12-17 20:20:54.756 test[8581:c07] <NSManagedObject: 0xaa52ef0> (entity: Card; id: 0xaa4ec40 <x-coredata://CF3F8F22-FE94-452E-9BFB-D4216847C8D4/Card/p14> ; data: {
chlore = 0;
"continue_filtering" = 1;
"created_at" = "2012-12-01 09:55:05 +0000";
customer = "0x7533700 <x-coredata://CF3F8F22-FE94-452E-9BFB-D4216847C8D4/Customer/p1>";
"cyanuric_acid" = 9;
date = "2012-12-01 00:00:00 +0000";
"electricity_day_used" = 67;
"electricity_night_used" = 67;
"end_time" = "2012-12-01 10:54:00 +0000";
"filtering_end" = "2000-01-01 09:54:00 +0000";
"filtering_start" = "2000-01-01 09:54:00 +0000";
furniture = 1;
"furniture_to_get" = "";
heater = 0;
id = 39;
miscellaneous = Zer;
ph = "7,2";
"regulation_temperature" = 56;
"start_time" = "2012-12-01 10:54:00 +0000";
"treatment_anti_algae" = 5;
"treatment_auto_stop_filling" = 0;
"treatment_chlore" = 5;
"treatment_filling_start" = 0;
"treatment_floculant" = 0;
"treatment_hypo_stick" = nil;
"treatment_hypochlorite" = 5;
"treatment_pebble" = 5;
"treatment_ph_less" = 5;
"treatment_ph_plus" = 5;
"updated_at" = "2012-12-01 09:55:05 +0000";
"water_quality" = "Eau bleue limpide";
"water_used" = 56;
works = (
);
})
但是當我做card.treatment_ph_less返回null。你有什麼想法,爲什麼?這個問題的根源是什麼?
我的字段被定義爲double。
我不明白的是:當我做卡片。調節溫度,我得到了「56」。但是對於所有的「處理_ *」屬性,我得到了空...如果我在壞的託管對象上下文中,一切都將爲空,對吧? – Sebastien
我不知道它是否可以幫助,但有唯一的字段聲明爲double ... – Sebastien
如果您的託管對象在不同的線程/隊列上,而不是它所屬的上下文創建的,那麼技術上的行爲會未定義。我不得不承認Core Data如何將事物描述爲文字(經典的他們都是對象)的經驗有限,所以我不能憑經驗確切地說出什麼是未定義的行爲。儘管如果你正在使用正確的隊列/線程進行對象訪問,那麼我肯定可以說我的猜測是錯誤的。 – Tommy