Can't change input Value in Swift 4.2
up vote
-1
down vote
favorite
I have an input UITextField
and want to change his value.
I defined this UITextField
like this:
@IBOutlet weak var valueInput: UITextField!
Than in viewDidLoad()
I make delegate
- self
:
valueInput?.delegate = self
and then in viewDidLoad
I try to assign value to input like this:
if let priceIn = self.valueIn Input {
valueIn.text! = strPr // (this is var and it has String format I've checked it, and I also try to make print(strPr) and I get a value)
}
Unfortunately this string is not working:
valueIn.text! = strPr
But if I write something like this
valueIn.text! = "11"
This one will work.
I've tried to to something like this also, but it's not working also:
valueIn.text! = "(strPr)"
Anyone have any ideas?
Thanks for any answer, hope somebody had the same problem and know how to resolve it.
ios swift swift4.2 xcode10.1
|
show 6 more comments
up vote
-1
down vote
favorite
I have an input UITextField
and want to change his value.
I defined this UITextField
like this:
@IBOutlet weak var valueInput: UITextField!
Than in viewDidLoad()
I make delegate
- self
:
valueInput?.delegate = self
and then in viewDidLoad
I try to assign value to input like this:
if let priceIn = self.valueIn Input {
valueIn.text! = strPr // (this is var and it has String format I've checked it, and I also try to make print(strPr) and I get a value)
}
Unfortunately this string is not working:
valueIn.text! = strPr
But if I write something like this
valueIn.text! = "11"
This one will work.
I've tried to to something like this also, but it's not working also:
valueIn.text! = "(strPr)"
Anyone have any ideas?
Thanks for any answer, hope somebody had the same problem and know how to resolve it.
ios swift swift4.2 xcode10.1
What do you mean by "it's not working"? Do you get a compile time error? What is the type ofvalueIn
?
– Daniel T.
Nov 16 at 14:04
self.valueIn Input
— what does it even mean? It is not valid Swift.
– user28434
Nov 16 at 14:10
1
Show the code wherestrPr
is declared and populated – by the way please use more descriptive variable names. I guess it's a timing/asynchonous issue. And if you meanif let priceIn = self.valueInput
this optional binding is pointless because the outlet is connected reliably beforeviewDidLoad
is called.
– vadian
Nov 16 at 14:14
Yesprint(strPr
) beforevalueIn.text! = strPr
– canister_exister
Nov 16 at 14:47
Delete this lineif let priceIn = self.valueIn Input {
– canister_exister
Nov 16 at 14:52
|
show 6 more comments
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I have an input UITextField
and want to change his value.
I defined this UITextField
like this:
@IBOutlet weak var valueInput: UITextField!
Than in viewDidLoad()
I make delegate
- self
:
valueInput?.delegate = self
and then in viewDidLoad
I try to assign value to input like this:
if let priceIn = self.valueIn Input {
valueIn.text! = strPr // (this is var and it has String format I've checked it, and I also try to make print(strPr) and I get a value)
}
Unfortunately this string is not working:
valueIn.text! = strPr
But if I write something like this
valueIn.text! = "11"
This one will work.
I've tried to to something like this also, but it's not working also:
valueIn.text! = "(strPr)"
Anyone have any ideas?
Thanks for any answer, hope somebody had the same problem and know how to resolve it.
ios swift swift4.2 xcode10.1
I have an input UITextField
and want to change his value.
I defined this UITextField
like this:
@IBOutlet weak var valueInput: UITextField!
Than in viewDidLoad()
I make delegate
- self
:
valueInput?.delegate = self
and then in viewDidLoad
I try to assign value to input like this:
if let priceIn = self.valueIn Input {
valueIn.text! = strPr // (this is var and it has String format I've checked it, and I also try to make print(strPr) and I get a value)
}
Unfortunately this string is not working:
valueIn.text! = strPr
But if I write something like this
valueIn.text! = "11"
This one will work.
I've tried to to something like this also, but it's not working also:
valueIn.text! = "(strPr)"
Anyone have any ideas?
Thanks for any answer, hope somebody had the same problem and know how to resolve it.
ios swift swift4.2 xcode10.1
ios swift swift4.2 xcode10.1
edited Nov 16 at 14:07
vadian
138k13144165
138k13144165
asked Nov 16 at 13:54
Vitaliy Mckay
608
608
What do you mean by "it's not working"? Do you get a compile time error? What is the type ofvalueIn
?
– Daniel T.
Nov 16 at 14:04
self.valueIn Input
— what does it even mean? It is not valid Swift.
– user28434
Nov 16 at 14:10
1
Show the code wherestrPr
is declared and populated – by the way please use more descriptive variable names. I guess it's a timing/asynchonous issue. And if you meanif let priceIn = self.valueInput
this optional binding is pointless because the outlet is connected reliably beforeviewDidLoad
is called.
– vadian
Nov 16 at 14:14
Yesprint(strPr
) beforevalueIn.text! = strPr
– canister_exister
Nov 16 at 14:47
Delete this lineif let priceIn = self.valueIn Input {
– canister_exister
Nov 16 at 14:52
|
show 6 more comments
What do you mean by "it's not working"? Do you get a compile time error? What is the type ofvalueIn
?
– Daniel T.
Nov 16 at 14:04
self.valueIn Input
— what does it even mean? It is not valid Swift.
– user28434
Nov 16 at 14:10
1
Show the code wherestrPr
is declared and populated – by the way please use more descriptive variable names. I guess it's a timing/asynchonous issue. And if you meanif let priceIn = self.valueInput
this optional binding is pointless because the outlet is connected reliably beforeviewDidLoad
is called.
– vadian
Nov 16 at 14:14
Yesprint(strPr
) beforevalueIn.text! = strPr
– canister_exister
Nov 16 at 14:47
Delete this lineif let priceIn = self.valueIn Input {
– canister_exister
Nov 16 at 14:52
What do you mean by "it's not working"? Do you get a compile time error? What is the type of
valueIn
?– Daniel T.
Nov 16 at 14:04
What do you mean by "it's not working"? Do you get a compile time error? What is the type of
valueIn
?– Daniel T.
Nov 16 at 14:04
self.valueIn Input
— what does it even mean? It is not valid Swift.– user28434
Nov 16 at 14:10
self.valueIn Input
— what does it even mean? It is not valid Swift.– user28434
Nov 16 at 14:10
1
1
Show the code where
strPr
is declared and populated – by the way please use more descriptive variable names. I guess it's a timing/asynchonous issue. And if you mean if let priceIn = self.valueInput
this optional binding is pointless because the outlet is connected reliably before viewDidLoad
is called.– vadian
Nov 16 at 14:14
Show the code where
strPr
is declared and populated – by the way please use more descriptive variable names. I guess it's a timing/asynchonous issue. And if you mean if let priceIn = self.valueInput
this optional binding is pointless because the outlet is connected reliably before viewDidLoad
is called.– vadian
Nov 16 at 14:14
Yes
print(strPr
) before valueIn.text! = strPr
– canister_exister
Nov 16 at 14:47
Yes
print(strPr
) before valueIn.text! = strPr
– canister_exister
Nov 16 at 14:47
Delete this line
if let priceIn = self.valueIn Input {
– canister_exister
Nov 16 at 14:52
Delete this line
if let priceIn = self.valueIn Input {
– canister_exister
Nov 16 at 14:52
|
show 6 more comments
1 Answer
1
active
oldest
votes
up vote
0
down vote
These lines are wrong:
valueIn.text! = strPr
valueIn.text! = "11"
valueIn.text!
should only appear on the right side, in case you are sure valueIn references a valid object (not nil) and text is declared as var text: String?
Not sure exactly how your variables are declared, but try something like this:
valueIn.text = "11"
Or, if strPtr is an Optional, try this:
if let strPr = strPr {
valueIn.text = strPr
print("New valueIn.text: (valueIn.text!)")
}
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
These lines are wrong:
valueIn.text! = strPr
valueIn.text! = "11"
valueIn.text!
should only appear on the right side, in case you are sure valueIn references a valid object (not nil) and text is declared as var text: String?
Not sure exactly how your variables are declared, but try something like this:
valueIn.text = "11"
Or, if strPtr is an Optional, try this:
if let strPr = strPr {
valueIn.text = strPr
print("New valueIn.text: (valueIn.text!)")
}
add a comment |
up vote
0
down vote
These lines are wrong:
valueIn.text! = strPr
valueIn.text! = "11"
valueIn.text!
should only appear on the right side, in case you are sure valueIn references a valid object (not nil) and text is declared as var text: String?
Not sure exactly how your variables are declared, but try something like this:
valueIn.text = "11"
Or, if strPtr is an Optional, try this:
if let strPr = strPr {
valueIn.text = strPr
print("New valueIn.text: (valueIn.text!)")
}
add a comment |
up vote
0
down vote
up vote
0
down vote
These lines are wrong:
valueIn.text! = strPr
valueIn.text! = "11"
valueIn.text!
should only appear on the right side, in case you are sure valueIn references a valid object (not nil) and text is declared as var text: String?
Not sure exactly how your variables are declared, but try something like this:
valueIn.text = "11"
Or, if strPtr is an Optional, try this:
if let strPr = strPr {
valueIn.text = strPr
print("New valueIn.text: (valueIn.text!)")
}
These lines are wrong:
valueIn.text! = strPr
valueIn.text! = "11"
valueIn.text!
should only appear on the right side, in case you are sure valueIn references a valid object (not nil) and text is declared as var text: String?
Not sure exactly how your variables are declared, but try something like this:
valueIn.text = "11"
Or, if strPtr is an Optional, try this:
if let strPr = strPr {
valueIn.text = strPr
print("New valueIn.text: (valueIn.text!)")
}
answered Nov 17 at 14:35
ppalancica
2,81541832
2,81541832
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53339241%2fcant-change-input-value-in-swift-4-2%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What do you mean by "it's not working"? Do you get a compile time error? What is the type of
valueIn
?– Daniel T.
Nov 16 at 14:04
self.valueIn Input
— what does it even mean? It is not valid Swift.– user28434
Nov 16 at 14:10
1
Show the code where
strPr
is declared and populated – by the way please use more descriptive variable names. I guess it's a timing/asynchonous issue. And if you meanif let priceIn = self.valueInput
this optional binding is pointless because the outlet is connected reliably beforeviewDidLoad
is called.– vadian
Nov 16 at 14:14
Yes
print(strPr
) beforevalueIn.text! = strPr
– canister_exister
Nov 16 at 14:47
Delete this line
if let priceIn = self.valueIn Input {
– canister_exister
Nov 16 at 14:52