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?
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];
}
You are not using the "text" property of the UITextField.
It should be:
field0.text = lstaInfo[0];
Try to call setFields on viewWillAppear
. The viewDidLoad
method only is called once, when the view is loaded.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.