read and write using NSKeyedArchiver, ios
===

Below is a class to read and write data using nsarchive

**Data.m**

    -(id)init {
        self        =   [super init];
        if(self) {
            arr     =   [[NSMutableArray alloc] init];
        }
        return self;
    }
    
    -(NSString *)getPath {
        NSArray     *paths          =   NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        NSString    *documentPath;
        
    	if ([paths count] > 0)
    		documentPath            =   [paths objectAtIndex:0];
        
        NSString *draftDataPath     =   [documentPath stringByAppendingPathComponent:@"draftData.dat"];
        return draftDataPath;
    }
    
    -(void)saveDataToDisk {
        NSString *path              =   [self getPath];
        [NSKeyedArchiver archiveRootObject:arr toFile:path];
        
    }
    
    -(void)loadDataFromDisk {
        NSString    *path           =   [self getPath];
        self.arr                    =   [NSKeyedUnarchiver unarchiveObjectWithFile:path];
    }

At later on, I am adding some objects into `arr` by doing
CustomerClass.m

    - (void) viewDidLoad {
    
    Data *data = [[Data alloc] init];
    [data.arr addObject:myObject1]
    [data.arr addObject:myObject2]
    [data.arr addObject:myObject3]
    [data saveDataToDisk];
    }

At DisplayData.m, I want to check data.arr by

    - (void) viewDidLoad {
       Data *data = [[Data alloc] init];
       [data loadDataFromDisk];
    
       NSLog(@"length of array is %d",[data.arr count]);
    
    }

On the console, I am getting

    length of array is 1


I thought it should be 3 after all. 

Please point out what I have just made a mistake in the middle of work if you have any clues about it.