【发布时间】:2013-08-03 01:06:18
【问题描述】:
我如何忽略结果中的最后 2 行,因为该行显示如下统计信息:
---
1113 entries, 25351 bytes used, 7417 bytes free.
我也不确定我是否在下面收到此错误: * 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“* -[NSDictionary initWithObjects:forKeys:]:对象计数 (1116) 与键计数 (1117) 不同”
NSString *result ...
NSArray *strings = [result componentsSeparatedByCharactersInSet:
[NSCharacterSet characterSetWithCharactersInString:@"=\n"]];
NSMutableArray *keys = [NSMutableArray new];
NSMutableArray *values = [NSMutableArray new];
for (int i = 0; i < strings.count; i+=1) {
if (i % 2 == 0) { // if i is even
[keys addObject:strings[i]];
}
else {
[values addObject:strings[i-1]];
}
}
Sample data:
NC_AllowedWebHosts=
NC_BgeLAN=br1
NC_Doc=/tmp/dhcpd
NC_ExPts=1863
NC_Redirect=1
[...]
bt_binary_custom=/path/to/binaries/directory
bt_blocklist=0
bt_blocklist_url=http://list.g.com/?list=bt_level1
bt_check=1
【问题讨论】:
标签: ios objective-c cocoa nsstring nsarray