Problem in Reading value using NSUserDefaults from one view to another view
<p>I used NSUserDefaults to store a value.</p>

<p>I store some integer value in NSUserDefaults like as follows in first view.</p>

<p>I declared in interface file as follows..</p>

<pre><code>NSUserDefaults *prefs;
    @property(nonatomic,retain) IBOutlet NSUserDefaults *prefs;
</code></pre>

<p>Then i used in class file as follows</p>

<pre><code>   @synthesize passwordfield,prefs;
</code></pre>

<p>here passwordfield is the name of UITextField</p>

<pre><code>NSInteger myInteger = [passwordfield.text integerValue];
[prefs setInteger:myInteger forKey:@"integerKey"];
[prefs synchronize];
NSInteger myInt = [prefs integerForKey:@"integerKey"];
NSLog(@"My integer Value: %d",myInt);
</code></pre>

<p>Then i move to next view using navigation controller.</p>

<p>but i cant read NSUserDefaults's value from the first view.</p>

<p>I used code like as follows in second view.</p>

<pre><code>PasswordCheckViewController *nextController = [[PasswordCheckViewController alloc] initWithNibName:@"PasswordCheckViewController" bundle:nil];
NSLog(@"Pass in Next: %d",[nextController.prefs integerForKey:@"integerKey"]);
</code></pre>

<p>But the output as follows.</p>

<pre><code> Pass in Next: 0
</code></pre>

<p>If anybody knows to get value from the first view to second view using NSUserDefaults please help me.</p>

<p>Thanks.</p>
