Using setValue of EntryView() instead of setPlaceholder - swift

I'm setting the Placeholder value of a EntryView() in my application to a value I'm retrieving from my database. But now I want to change my approach and instead set the value of the EntryView so that the user does not have to fill in the content.
This is my code to retrieve the value and then set the Placeholder:
let firstName = dict["firstName"] as? String
...
self.firstNameEntryView.setPlaceholder(firstName!)
This functionality works fine and it populates the correct value as the placeholder. But how do I make the String value of 'firstName' be set as the actual value in my firstNameEntryView?
I tried this approach:
self.firstNameEntryView.setValue(String?.self, forKey: firstName!)
But I get this error: " setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key Thomas"
Thomas is the correct value from my db. Am I using the setValue method incorrectly?

I ended up figuring this out through trial and error.
The code to set the text is as follows:
self.firstNameEntryView.textField.text?.append(firstName!)

Related

cannot set accessibilityValue property

I'm trying to set an accessibilityValue property in swift application.
It doesn't work , while I'm trying to inspect the element with appium , the actual value is different from the value I've tried to set.
In case and I'm setting next values :
self?.isAccessibilityElement = true
self?.accessibilityLabel = "Header"
self?.accessibilityValue = Some dynamic value
The value property is being override by the accessibilityLabel value
Any idea what has gone wrong ?
Thanks

Realm object property misses its value, but I can see it when printing the whole object

I stumbled upon a weird thing when trying to fetch an object from my Realm (iOS, Swift, Realm version 0.98.2)
print("speaker:")
print(RealmProvider.appRealm.objects(FavoriteSpeaker).first!)
Correctly dumps my object in the console:
speaker:
FavoriteSpeaker {
name = Ashley Nelson-Hornstein;
}
But when I try to get the name property's value:
print("speaker name:")
print(RealmProvider.appRealm.objects(FavoriteSpeaker).first!.name)
I get an empty string 🤔
speaker name:
The four lines are together in my model's init method
Update 1: I found an answer that suggests that you merely don't see the values when printed in the Console: Realm object is missing all properties except primaryKey but I also tried displaying the name property via an alert view and that is also empty.
Update 2: Just to make sure that everything happens sequentially and on the same thread I did this:
let favorite1 = FavoriteSpeaker()
favorite1.name = "Debbie Downer"
try! RealmProvider.appRealm.write {
RealmProvider.appRealm.deleteAll()
RealmProvider.appRealm.add(favorite1)
}
print("speaker:")
print(RealmProvider.appRealm.objects(FavoriteSpeaker.self).first!)
print("speaker name:")
print(RealmProvider.appRealm.objects(FavoriteSpeaker.self).first!.name)
But the result is the same - printing name prints an empty string
The name property is probably not declared as dynamic, which leads to it reading the nil value stored on the object itself rather than reading the data from the Realm.

How to fetch value from custom multifield component?

I have created a multifield custom widget having two fields with names ./urlLink and ./urlText.
Now i m trying to fetch the values from widget into the component's jsp with following code
String property = properties.get("./urlLink",String[].class);
for(String value: property ) {
out.print(value);
}
out.print(property);
But i am not able to get its value instead i m getting error.
If you're getting a property and it contains a string value, you need to use the method getString() - that way when you have the property, you can set the string to the value by doing something like this:
Property property = properties.get("./urlLink",String.class);
String value = property.getString();
Just a side note, if your return is supposed to be a string array, your type that you're putting the values in should be a string array.
String[] value
Check out the documentation on day.com for Properties and getting the values inside them.
Looks like a typo: you don't prefix a property name with .\ when accessing it.
My guess is you got a NullPointerException, right? That's because there's no ./urlLink property in the value map (properties). You should check against that anyway (so that it's not thrown on a fresh page with no content).
If that doesn't help -- double check that you have the properties in the content (call your page with .xml or .infinite.json extensions, and then double check if you can read them as plain strings (you should be able to -- CRX does some magic, smart type conversions).
It's good to register custom xtype as :
// registering the custom widget with the name dualfield
CQ.Ext.reg("dualfield", CQ.Ext.form.DualField);
Then u can easily fetch the value as :
String[] data = properties.get("multi",String[].class);
Here multi is the name of widget having multifield as xtype

Struts 2 - Date instance become String

When I submit the form, input error is occur. JourneyDate is instance of 'Date'. But ,here it become String which is not accepted by the setter and getter.
<s:hidden name="JourneyDate" value="%{JourneyDate}"></s:hidden>
I want JourneyPlan as Date Type, but it become String.
Try intercepting the value before passing it to the getter/setter. For example send JourneyDateString from your form, create a Date from the String, and then pass that to your getter/setter. Something like:
public void setJourneyDateString(String journeyDateString)
{
//journeyDateString could be "2013-03-28" for example
Date journeyDate = new SimpleDateFormat("yyyy-MM-dd").parse(journeyDateString);
setJourneyDate(journeyDate);
}
The object that you've set in the value attribute will keep it's type as Date. Then you need to define corresponding setter in the action to set the value of the Date. It will convert to string if you place the value in the body of the tag.

key value coding-compliant for NSObject class?

I've created a singleton class that loads a plist. I keep getting this error when I try to set a value:
[<MyPlist 0x1917bc0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key test.'
I have one key in the plist file. The key is named "test" and has no value associated with it. I set the value like this:
[[PlistManager sharedManager].plist setValue:#"the title value" forKey:#"test"];
I look at the set plist dictionary and see this from within PlistManager:
po self.plistDictionary
{
test = "";
}
I get the error just as I'm leaving PlistManager in the debugger. PlistManager is of type NSObject. So no xibs. Any ideas on what I need to do?
Could it be that you are using a non-mutable dictionary instead of NSMutableDictionary?