Issue with member of custom object
<p>I have a custom class</p>

<pre><code>@interface XYZ : NSObject 
</code></pre>

<p>{
   int sum;
   ....
}</p>

<p>@property (nonatomic, assign) int sum;
.....</p>

<p>In my method, I initialize a new class as:</p>

<pre><code>XYZ *myClass = [[XYZ alloc] init];
</code></pre>

<p>Then in a for loop in that method, I assign the value of sum based on a condition:</p>

<pre><code>if(   )
</code></pre>

<p>{
   myClass.sum = val;</p>

<p>NSLog(@"%d", myClass.sum);
}</p>

<p>The NSLog prints the correct value. (The value here is = 6)</p>

<p>Now, once I am out of the for loop, I again print the value of sum using the same NSLog statement:</p>

<pre><code>NSLog(@"%d", myClass.sum);
</code></pre>

<p>This time the value is 0. I never understood why. Thinking that the value was not retained, I even used the NSString and NSNumber data types but I have not had any success.</p>

<p>Is it something very basic I am missing? Please advice.</p>

<p>Thanks for any help in advance</p>
