Why does this code:
QuadTree *q1 = [[QuadTree alloc] initWithCGRect:CGRectMake(m_bounds.origin.x, m_bounds.origin.y, halfWidth, halfHeight)];
[m_nodes addObject:q1];
[m_nodes addObject:[[QuadTree alloc] initWithCGRect:CGRectMake(m_bounds.origin.x, m_bounds.origin.y + halfHeight, halfWidth, halfHeight)]];
[m_nodes addObject:[[QuadTree alloc] initWithCGRect:CGRectMake(m_bounds.origin.x + halfWidth, m_bounds.origin.y, halfWidth, halfHeight)]];
[m_nodes addObject:[[QuadTree alloc] initWithCGRect:CGRectMake(m_bounds.origin.x + halfWidth, m_bounds.origin.y + halfHeight, halfWidth, halfHeight)]];
NSLog(@"nodes count %lu", (unsigned long)m_nodes.count);
Returns this message:
malloc: *** error for object 0xa852234: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
nodes count 0
1. what does the incorrect checksum message means and how to solve it?
2. why does the array count is zero?
Notes: This is the declaration of m_nodes.
NSMutableArray *m_nodes;
m_nodes = [[NSMutableArray alloc] initWithCapacity:4];