Test class instance appears in my model?
<p>I don't know how to explain it, it is really weird.</p>
<p>I'm testing some methods of a class, just use XCTest, I didn't use any other test framework in this test case.</p>
<p>At the first time I convert a dictionary to a model, and set it to a local variable, it works well.</p>
<p>But at the second time(just after first time), it went wrong. I have traced the stack, and found just before local variable being set with the new converted model, everything is <strong>correct</strong>, the return value of <code>initWithDict</code> is correct. But when the return value is set to local variable, something weird appears.</p>
<p>The pointer of the local variable is not the pointer of return value. And every property in model messed up. Even one property is set to a <strong>XXXXTests</strong> class instance. It should be my <strong>test class</strong>, how I can get it and set it to model???</p>
<p><a href="https://i.stack.imgur.com/CGhLa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CGhLa.png" alt="first time" /></a></p>
<hr />
<p><a href="https://i.stack.imgur.com/VqoDM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VqoDM.png" alt="second time" /></a></p>
<p><strong>EDIT</strong></p>
<pre><code>-(void)testFindSubDictionaryWithDictionary{
    NSMutableDictionary* dict=[ToolMethod recursivelyMutateArrayOrDictionary:_miniComponentTreeData];
    ComponentTreeDataManager* componentTreeDataManager=[ComponentTreeDataManager manager];
    NSMutableDictionary* obj=[componentTreeDataManager findSubDictionaryWithDictionary:dict InvertListPath:@&quot;dynamic,a_new&quot; identification:@&quot;triger_xinsui&quot;];
}
</code></pre>
<p>And I also found that modifying my input dictionary will not affect the result. The <em>second</em> time will go wrong, not first not third not fourth, just second.</p>
<p>But if I copy <code>ComponentTreeDataModel* model=[[ComponentTreeDataModel alloc]initWithDict:obj];</code>, and make something like:</p>
<pre><code>ComponentTreeDataModel* model=[[ComponentTreeDataModel alloc]initWithDict:obj];
ComponentTreeDataModel* model1=[[ComponentTreeDataModel alloc]initWithDict:obj];
ComponentTreeDataModel* model2=[[ComponentTreeDataModel alloc]initWithDict:obj];
ComponentTreeDataModel* model3=[[ComponentTreeDataModel alloc]initWithDict:obj];
</code></pre>
<p>Then, all of those duplicated models are right, everytime.</p>
<p>Anyone can help me, and explain what it is???</p>