无法将文本从UITextField添加到数组 [英] Unable to add text from UITextField to an Array

查看:60
本文介绍了无法将文本从UITextField添加到数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我在其上方有一个自定义视图表格单元格和一个文本字段。我想从 UItextfield 获取文本,并将其放入 NSMutableArray 中。

Currently I have a custom view table cell and a text field just above it. I want to get the text from the UItextfield and put that into an NSMutableArray.

伪代码:

String text = _textfield.text;
[array addObject:text];
NSLog{array}

在我的头文件中,我创建了文本字段和数组。

In my header file I have created the textfield and the array.

我目前收到错误:'CustomTableView:[340:11303] array:(null)' NSLog。

I currently receive the error : 'CustomTableView:[340:11303] array: (null)' when I NSLog.

我不确定为什么文本字段中的文本没有被添加到数组中。如果有人能够提供帮助,将不胜感激。

I am not to sure why the text from the textfield is not getting added to the array. If any one is able to help it will be greatly appreciated.

注意-我的文本字段位于自定义单元格上方,不在其中。我什至尝试将字符串直接直接添加到数组中并记录下来,但我得到了相同的错误。因此,我认为这与数组有关。

Note - My textfield is above the custom cell not in it. I have even tried just adding a string to the array directly and logging it and I get the same error. So I would assume that this is something to do with the array.

推荐答案

您初始化了Array。采用MutableArray并将其初始化。

did you initialize your Array.take a MutableArray and initialize it.

       NSMutableArray *array=[NSMutableArray alloc]init];

这篇关于无法将文本从UITextField添加到数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆