I have this text read into an NSString *responce which I am trying to parse into an array.
total: used: free: shared: buffers: cached:
Mem: 30412800 16805888 13606912 0 1581056 4837376
Swap: 0 0 0
MemTotal: 29700 kB
MemFree: 13288 kB
MemShared: 0 kB
Buffers: 1544 kB
Cached: 4724 kB
SwapCached: 0 kB
Active: 1197 kB
Inactive: 699 kB
HighTotal: 0 kB
HighFree: 0 kB
LowTotal: 29700 kB
LowFree: 13288 kB
SwapTotal: 0 kB
SwapFree: 0 kB
Dirty: 0 kB
Writeback: 0 kB
Mapped: 277 kB
Slab: 132 kB
CommitLimit: 14848 kB
Committed_AS: 3400 kB
PageTables: 1567 kB
VmallocTotal: 1048404 kB
VmallocUsed: 17208 kB
VmallocChunk: 1031168 kB
If I read into an array like this, I get over 300 objects in the array!
NSMutableArray *items2 = [NSMutableArray arrayWithArray:[responce componentsSeparatedByString:@" "]];
NSLog(@"count of memory array = %i",[items2 count]);
I add this to try and remove all the blank ones, but still end up with 170.
for (int i=0; i<[items2 count]; i++) {
NSString *str = [items2 objectAtIndex:i];
if([str length]==0 || !str || str==nil) {
[items2 removeObjectAtIndex:i];
}
}
This NSLog statement tells me that most of them are zero length, why where they not removed?
for (int i=0; i<[items2 count]; i++) {
NSLog(@"%i=%@ / length=%d",i,[items2 objectAtIndex:i],[[items2 objectAtIndex:i] length]);
}