gpt4 book ai didi

ios - NSString 不会添加到 NSMutableArray

转载 作者:行者123 更新时间:2023-11-28 22:09:54 25 4
gpt4 key购买 nike

在我的应用程序中我使用

[theMutableArray addObject:theString];

几次,每次都有效,但是当尝试添加另一个 View 时,它不会添加。

我知道我的字符串不为空,因为我有

NSLog(@"%@, %@", theString, theMutableArray);

然后返回"字符串值", (null)

在我的 viewDidLoad 中有

theMutableArray = [[NSMutableArray alloc] init];

在我尝试添加它的地方

theString = [alertView textFieldAtIndex:0].text;
[theMutableArray addObject:theString];
NSLog(@"%@, %@", theString, theMutableArray);

有没有错别字?还是我忘记了什么?

最佳答案

你说的

NSLog(@"%@, %@", theString, theMutableArray);

返回“字符串值”,(null)。那么你期待什么?您的 theMutableArray 似乎为零,这就是您无法向其添加任何内容的原因。

关于ios - NSString 不会添加到 NSMutableArray,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23172900/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com