Reputation: 144
I have an array located within the variable lstaInfo, as follows:
[0] = fruits
[1] = bee
[2] = computer
[3] = cars
And I'm entering every part of the array in its respective text field, as follows:
-(void)setFields{
field0.text = lstaInfo[0];
field1.text = lstaInfo[1];
field2.text = lstaInfo[2];
field3.text = lstaInfo[3];
}
I'm calling setFields
function in viewDidLoad
, but every time I run the simulator, it crashes and returns me an error message called:
Thread 1: signal SIGABRT
The array is perfect and IBOutlets also, could someone help me?
Upvotes: 0
Views: 41
Reputation: 2579
Setting the array:
NSArray *lstaInfo = @[@"fruits",@"bee", @"computer", @"car"];
Then populating fields:
-(void)setFields{
field0.text = lstaInfo[0];
field1.text = lstaInfo[1];
field2.text = lstaInfo[2];
field3.text = lstaInfo[3];
}
Upvotes: 1
Reputation: 835
Try to call setFields on viewWillAppear
. The viewDidLoad
method only is called once, when the view is loaded.
Upvotes: 1
Reputation: 835
You are not using the "text" property of the UITextField.
It should be:
field0.text = lstaInfo[0];
Upvotes: 1