NSUserDefault doesn't works
<p>i am developing an app which has a evernote integration,everything works perfect but my problem is ,if i login with my account and uplode or downlode note to my aPP,then i logout from the evernote and login as a another user,it stills downlod and uplode note to previous account,,but login is sucess.
i put NsuserDefault for username and password textfileds and syncoronize it and pass it in evernote singlton shared class.my login looks like this</p>

<pre><code>-(IBAction)_clickevernotelogin:(id)sender
{


    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    // Keep this key private
    NSString *consumerKey = [[[NSString alloc]
                              initWithString: @"myapp" ] autorelease];
    [[NSUserDefaults standardUserDefaults] setObject:consumerKey forKey:@"consumerkeyevrnote"];
    NSString *consumerSecret = [[[NSString alloc]
                                 initWithString: @"agft5623636"] autorelease];

    NSURL *userStoreUri = [[[NSURL alloc]
                            initWithString: @"https://www.evernote.com/edam/user"] autorelease];
    NSString *noteStoreUriBase = [[[NSString alloc]
                                   initWithString: @"https://www.evernote.com/edam/note/"] autorelease];

    // These are for test purposes. At some point the user will provide his/her own.
    NSString *username = [[[NSString alloc]
                           initWithString: _txtevernoteUsername.text] autorelease];
    NSString *password = [[[NSString alloc]
                           initWithString: _txtevernotepasswrd.text] autorelease];
        [[NSUserDefaults standardUserDefaults] setObject:_txtevernoteUsername.text forKey:@"usernameever"];
        [[NSUserDefaults standardUserDefaults] setObject:_txtevernotepasswrd.text forKey:@"passwrdevernote"];
         [[NSUserDefaults standardUserDefaults]synchronize];

    THTTPClient *userStoreHttpClient = [[[THTTPClient alloc]
                                         initWithURL:userStoreUri] autorelease];
    TBinaryProtocol *userStoreProtocol = [[[TBinaryProtocol alloc]
                                           initWithTransport:userStoreHttpClient] autorelease];
    EDAMUserStoreClient *userStore = [[[EDAMUserStoreClient alloc]
                                       initWithProtocol:userStoreProtocol] autorelease];
    EDAMNotebook* defaultNotebook = NULL;

    BOOL versionOk = [userStore checkVersion:@"Cocoa EDAMTest" :
                      [EDAMUserStoreConstants EDAM_VERSION_MAJOR] :
                      [EDAMUserStoreConstants EDAM_VERSION_MINOR]];

    if (versionOk == YES)
    {

        @try {

            NSError *error = nil;
            NSString *unameever = _txtevernoteUsername.text;

            NSString *pwdever   = _txtevernotepasswrd.text;


            [[NSUserDefaults standardUserDefaults] setObject:unameever forKey:@"usernameever"];
            BOOL flag = [SFHFKeychainUtils storeUsername:unameever andPassword:pwdever forServiceName:@"mybibleappever" updateExisting:TRUE error:&amp;error];
            EDAMAuthenticationResult* authResult =
            [userStore authenticate:username :password
                                   :consumerKey :consumerSecret];
            EDAMUser *user = [authResult user];
            NSString *authToken = [authResult authenticationToken];
            NSLog(@"Authentication was successful for: %@", [user username]);
            NSLog(@"Authentication token: %@", authToken);
             [[NSUserDefaults standardUserDefaults] setObject:authToken forKey:@"usernameevernotetocken"];
            [[NSUserDefaults standardUserDefaults] setObject:[user username] forKey:@"usernameevernoteshow"]; 
            NSURL *noteStoreUri =  [[[NSURL alloc]
                                     initWithString:[NSString stringWithFormat:@"%@%@",
                                                     noteStoreUriBase, [user shardId]] ]autorelease];
        }
        @catch (EDAMUserException * e) {
            NSString * errorMessage = [NSString stringWithFormat:@"Please enter valid username &amp; password", [e errorCode]];
            UIAlertView *alertDone = [[UIAlertView alloc] initWithTitle: @"Evernote" message: errorMessage delegate: self cancelButtonTitle: @"Ok" otherButtonTitles: nil];
            _acteverloginimage.hidden = YES;
            _acteverlogin.hidden =YES;
            [alertDone show];
            [alertDone release];
            return;
        }


        [pool drain];


}
</code></pre>

<p>my logout looks like this</p>

<pre><code> [_btnusernameshow setTitle:nil forState:UIControlStateNormal];
            NSError *error = nil;
            NSString *usernameever = [[NSUserDefaults standardUserDefaults] objectForKey:@"usernameever"];
            BOOL flag = [SFHFKeychainUtils deleteItemForUsername:usernameever andServiceName:@"mybibleappever" error:&amp;error];
            [[NSUserDefaults standardUserDefaults ]removeObjectForKey:@"usernameevernote"];
            [[NSUserDefaults standardUserDefaults ]removeObjectForKey:@"passwrdevernote"];
            [[NSUserDefaults standardUserDefaults ]removeObjectForKey:@"usernameevernotetocken"];
            [[NSUserDefaults standardUserDefaults ]removeObjectForKey:@"usernameever"];
</code></pre>

<p>my evernote singlton class which share the instance look like this
here i am passing the nsuerdefault value to change the authentication information to this class</p>

<pre><code>- (void) connect {

    if (authToken == nil) 
    {      
        // In the case we are not connected we don't have an authToken
        // Instantiate the Thrift objects
        NSURL * NSURLuserStoreUri = [[[NSURL alloc] initWithString: userStoreUri] autorelease];

        THTTPClient *userStoreHttpClient = [[[THTTPClient alloc] initWithURL:  NSURLuserStoreUri] autorelease];
        TBinaryProtocol *userStoreProtocol = [[[TBinaryProtocol alloc] initWithTransport:userStoreHttpClient] autorelease];
        EDAMUserStoreClient *userStore = [[[EDAMUserStoreClient alloc] initWithProtocol:userStoreProtocol] autorelease];


        // Check that we can talk to the server
        bool versionOk = [userStore checkVersion: applicationName :[EDAMUserStoreConstants EDAM_VERSION_MAJOR] :    [EDAMUserStoreConstants EDAM_VERSION_MINOR]];

        if (!versionOk) {
            // Alerting the user that the note was created
            UIAlertView *alertDone = [[UIAlertView alloc] initWithTitle: @"Evernote" message: @"Incompatible EDAM client protocol version" delegate: self cancelButtonTitle: @"Ok" otherButtonTitles: nil];

            [alertDone show];
            [alertDone release];

            return;
        }


       NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
          [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(evrloginnotif:) name:@"evrloginnotiff" object:nil]; 
        //Checks if there is a saved User Name      
        NSError *error = nil;
        if([defaults objectForKey:@"usernameever"]&amp;&amp;[defaults objectForKey:@"passwrdevernote"])
        {


            username = [defaults objectForKey:@"usernameever"];
            password  = [defaults objectForKey:@"passwrdevernote"];

             //BOOL flag = [SFHFKeychainUtils storeUsername:username andPassword:password forServiceName:@"mybibleappever" updateExisting:TRUE error:&amp;error];
            // Returned result from the Evernote servers after authentication
            EDAMAuthenticationResult* authResult =[userStore authenticate:username :password : consumerKey :consumerSecret];

            // User object describing the account
            self.user = [authResult user];
            // We are going to save the authentication token
            self.authToken = [authResult authenticationToken];
            // and the shard id
            self.shardId = [user shardId];

            // Creating the user's noteStore's URL
            noteStoreUri =  [[[NSURL alloc] initWithString:[NSString stringWithFormat:@"%@%@", noteStoreUriBase, shardId] ] autorelease];

            // Creating the User-Agent
            UIDevice *device = [UIDevice currentDevice];
            NSString * userAgent = [NSString stringWithFormat:@"%@/%@;%@(%@)/%@", applicationName,applicationVersion, [device systemName], [device model], [device systemVersion]]; 


            // Initializing the NoteStore client
            THTTPClient *noteStoreHttpClient = [[[THTTPClient alloc] initWithURL:noteStoreUri userAgent: userAgent timeout:15000] autorelease];
            TBinaryProtocol *noteStoreProtocol = [[[TBinaryProtocol alloc] initWithTransport:noteStoreHttpClient] autorelease];
            noteStore = [[[EDAMNoteStoreClient alloc] initWithProtocol:noteStoreProtocol] retain];

        }
    }
}
</code></pre>

<p>how to solve this bug,,thanks
<strong>EDIT</strong></p>

<p><strong>but when i rebuild the app,i am getting the correct notes from the username</strong></p>
