문제

I wrote this to quickly test

Why arent my settings being saved? The first time i run this i have 3(old)/3(current) elements. The second time i get 3(old)/5(current), third time 5(old)/5(current).

When i close the app the settings completely disappear. Its 3 again when i run it. I made no changes to the app. Why arent my settings being saved

    private void button2_Click(object sender, EventArgs e)
    {
        MyApp.Properties.Settings.Default.Reload();
        var saveDataold = MyApp.Properties.Settings.Default.Context;
        var saveData = MyApp.Properties.Settings.Default.Context;
        saveData["user"] = textBox1.Text;
        saveData["pass"] = textBox2.Text;
        MyApp.Properties.Settings.Default.Save();
    }
도움이 되었습니까?

해결책

자신만의 자물쇠를 작성할 필요가 없습니다.모델에서 원자 속성을 사용하고 ThreadSafe입니다.

편집

예, 그건 특성이 무엇입니까? https://developer.apple.com/library/ios/documentation/cocoa/conceptual/objectivec/chapters/ocproperties.html#//apple_ref/doc/uid/tp30001163-ch17-sw2 <./ P>

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top