NSTextField value is not updated immediately after model changes - nsuserdefaults

I bind the textfield with a key in NSUserDefaults and the "Chose File..." button modifies the model.
But the textfield is not updated after the button get clicked. I have to re-open the window to see the new value been populated into the textfield.
What am I missing here?

It's because my key has a dot "." in it which confused data binding.
It was:
[ defaults setValue: xxx forKey:#"proxy.url"]
It should be:
[ defaults setValue: xxx forKey:#"proxy_url"]

Related

Access form / textbox default value problem

I have an access continous form:
I placed a unbound text box txt1 in the header where user enters the number of the assignment. I want all rows in the form to have the same assignement number - entered only once in the header. (Later, txt2 would be hidden).
In the form, i added a another textbox and placed default value as =[txt1].
My problem is that this text is being populated only in the second row, when i start typing in the first row.
As this:
Refreshing does not help.
Any ideas?
Thank you!
Textbox 2 does not populate because the default value is not available when record edit is initiated by input into unbound textbox 1. Code will have to set Value of textbox 2 with the textbox 1 input. So with textbox 1 AfterUpdate event:
Me.textbox2 = Me.textbox1.
Alternative is to not use unbound textbox. Instead, use AfterUpdate event of textbox 2 to set its DefaultValue property. Subsequent records will populate with that value until user enters another and the DefaultValue will be reset.

Cannot use Add: action for NSTextField bound to NSArrayController

I have a view (created in a StoryBoard) that has a couple of NSTextFields and a slider control. I have one NSTextField that that takes the value of the another NSTextField and a sliderValue.
When I click the "Add" button (which is connected to the add: action of the array controller) all the values are added...except the value in the NSTextField with the "computed value". I can type in that field manually, and it works. Have looked on this site, apple documentation, and general google searches, but I'm not sure why I cannot add this data to the array controller. More details (code)...
NSTextField: Name **Gets added**
SliderValue: Grade **Gets added**
NSTextField: gradebookName **Only adds if manually typed in**
Code:
var txtGradeBookName: String
let sliderValueString = String(sender.integerValue)
txtGradeBookName = txtName.stringValue + "GradeBook" + sliderValueString
gradebookName.stringValue = txtGradeBookName
The ArrayController is bound to a Core Data model. Again, txtName and the Slider value gets added no problem...but gradebookName never gets added (unless I manually type it in)...and it's binding is set up identical to the the other two.

Adding default values to settings.bundle items?

I have noticed that some values in settings.bundle (Root.plist) do not allow you to associate a default value with them?
Is there a way to add a default field or is it simply a case of adding the appropriate defaults for these items inside the application using ...
NSDictionary *defaultSettings = [NSDictionary dictionaryWithObjectsAndKeys:#"Kinetic", #"IDBombs", nil];
[userDefaults registerDefaults:defaultSettings];
Just curious if I am doing this right or missing something?
Right mouse click on any row within the item, click Add row on the menu and choose Default value.

Setting Textbox Value with Button (iPhone SDK)

What code would I use if I wanted to use a button to add a point (.) into a any selected textbox which already has a value in it. I can easily do this;
textField.text = #".";
But this only works with one text box and clears the value.
textField doesn't mean any text field it is only connected to one.
If you have many variables referencing the text fields you have. just loop (using a for loop) through them and check for the one whose editing property is set to YES.
If you want to add a fullstop to the end of the text field's text use:
textField.text = [NSString stringByAppendingString:#"."];

How to get current value of UITextField in cocos2d 0.8.2?

Hi all I am using cocos2d 0.8.2 for my new game. I have added a UITextField in my game and on click of a button (this button is actually a sprite i m using ccTouchesEnded! ) i save text field's value in database, but whenever i access the value i am getting nil. if i initialize the textfield value by some string, it always give me only that value.
i.e.
[txtField setText:#"Enter Your Name"];
when i access the value of txtField on a click of button it always give me "Enter Your Name". Although the value is changing when i type in textField, but its not returning me the new value.
is this a issue with cocos2d 0.8.2 or i am missing something?
You don't save the entered text. You just set #"Enter your Name" as default text, that is displayed in the cell. You should have a look at the UITextFieldDelegate methods. You have to overwrite the method didEndEditing, that is called after your editing or typing in text has ended, and implement there a line that saves the current value. Here you can use something like this:
NSString *containerForTextFieldValue = textField.text;