I have an array like following example:
[
{
"lx": 144,
"ly": 57,
"mx": 144,
"my": 56
},
{
"lx": 321,
"ly": -4,
"mx": 298,
"my": 16
}
]
I want to set every element with its half value.
In short, I want something like following.
[
{
"lx": 72,
"ly": 28.5,
"mx": 72,
"my": 28
},
{
"lx": 160.5,
"ly": -2,
"mx": 149,
"my": 8
}
]
I am using following code:
NSMutableArray * tempArray = [NSMutableArray arrayWithCapacity:0];
for (int i = 0; i < jsonArray.count; i++)
{
NSMutableDictionary * tempDict = [NSMutableDictionary dictionaryWithDictionary:(NSDictionary *)jsonArray[i]];
tempDict[@"lx"] = @([tempDict[@"lx"] intValue]/2);
tempDict[@"ly"] = @([tempDict[@"ly"] intValue]/2);
tempDict[@"mx"] = @([tempDict[@"mx"] intValue]/2);
tempDict[@"my"] = @([tempDict[@"my"] intValue]/2);
[tempArray addObject:tempDict];
}
I have done it with a loop and it is working fine with small amount of data.
But when I have large data, App behaviour becomes slow.
Any help will be appreciated
Thanks...