NSMutableArray 中的 NSString 与 myString 中的不一样
NSString in NSMutableArray isn't the same on myString
我对 NSString
和 NSMutableArray
有疑问。
当我从可变数组中检索一个字符串时,它有更多的空格,我不明白为什么会这样。
我来解释一下,我有一个数组并通过查询(使用 sqlite3)填充它:
NSMutableArray *fileNameAttached = [[NSMutableArray alloc] initWithArray:[self.dbManager loadDataFromDB:query]];
是这样的:
<__NSArrayM 0x15e233980>(
<__NSArrayM 0x15e26afd0>(
Allegato N. 1
)
)
当我使用以下代码检索字符串 Allegato N.1 时:
NSString *test = [NSString stringWithFormat:@"%@", [fileNameAttached objectAtIndex:0] ];
字符串测试是这样的:
(
"Allegato N. 1"
)
为什么我的字符串不仅是:
Allegato N.1
当我把它放在标签中时,它是不正确的,因为包含 () 和空格。
数据库的查询是:
NSString *query = [NSString stringWithFormat:@"SELECT fileName FROM Attach WHERE ID = '%@';",ticketID];
并且工作完美,事实上,当我填充 tableview 单元格时它没问题。但我不明白,因为我的字符串测试包含 3 行空格更多。
请帮助我。
谢谢你,对不起我的英语。
在你的日志中有两个数组。
(
(
Allegato N. 1
)
)
有两个圆括号表示两个数组。
您正在获取类似 NSString *test = [NSString stringWithFormat:@"%@", [fileNameAttached objectAtIndex:0] ];
的数据
这意味着外部数组的第一个对象,所以它是另一个数组。所以你需要做类似
的事情
NSArray *temp =[fileNameAttached objectAtIndex:0];
NSString *test = [NSString stringWithFormat:@"%@", [temp objectAtIndex:0] ];
I think you are using appcoda's DBManager class to do this. If it is so then you everytime got two array when load query.
希望这会有所帮助:)
我对 NSString
和 NSMutableArray
有疑问。
当我从可变数组中检索一个字符串时,它有更多的空格,我不明白为什么会这样。
我来解释一下,我有一个数组并通过查询(使用 sqlite3)填充它:
NSMutableArray *fileNameAttached = [[NSMutableArray alloc] initWithArray:[self.dbManager loadDataFromDB:query]];
是这样的:
<__NSArrayM 0x15e233980>(
<__NSArrayM 0x15e26afd0>(
Allegato N. 1
)
)
当我使用以下代码检索字符串 Allegato N.1 时:
NSString *test = [NSString stringWithFormat:@"%@", [fileNameAttached objectAtIndex:0] ];
字符串测试是这样的:
(
"Allegato N. 1"
)
为什么我的字符串不仅是:
Allegato N.1
当我把它放在标签中时,它是不正确的,因为包含 () 和空格。 数据库的查询是:
NSString *query = [NSString stringWithFormat:@"SELECT fileName FROM Attach WHERE ID = '%@';",ticketID];
并且工作完美,事实上,当我填充 tableview 单元格时它没问题。但我不明白,因为我的字符串测试包含 3 行空格更多。
请帮助我。
谢谢你,对不起我的英语。
在你的日志中有两个数组。
(
(
Allegato N. 1
)
)
有两个圆括号表示两个数组。
您正在获取类似 NSString *test = [NSString stringWithFormat:@"%@", [fileNameAttached objectAtIndex:0] ];
这意味着外部数组的第一个对象,所以它是另一个数组。所以你需要做类似
的事情NSArray *temp =[fileNameAttached objectAtIndex:0];
NSString *test = [NSString stringWithFormat:@"%@", [temp objectAtIndex:0] ];
I think you are using appcoda's DBManager class to do this. If it is so then you everytime got two array when load query.
希望这会有所帮助:)