//in .h
NSMutableArray *amountSpend;
//in View did load
NSArray *path1 = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory1 = [path1 objectAtIndex:0];
NSString *fullFileName1 = [NSString stringWithFormat:@"%@amountSpend", documentsDirectory1];
amountSpend=[[NSMutableArray alloc]initWithContentsOfFile:fullFileName1];
if([amountSpend count]==0){
amountSpend=[NSMutableArray alloc]init];
}
//action when the data need to be saved
[amountSpend addObject:amount.text];
NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *fullFileName1 = [NSString stringWithFormat:@"%@amountSpend", documentsDirectory];
[amountSpend writeToFile:fullFileName1 atomically:NO];
NSMutableArray *amountSpend;
//in View did load
NSArray *path1 = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory1 = [path1 objectAtIndex:0];
NSString *fullFileName1 = [NSString stringWithFormat:@"%@amountSpend", documentsDirectory1];
amountSpend=[[NSMutableArray alloc]initWithContentsOfFile:fullFileName1];
if([amountSpend count]==0){
amountSpend=[NSMutableArray alloc]init];
}
//action when the data need to be saved
[amountSpend addObject:amount.text];
NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *fullFileName1 = [NSString stringWithFormat:@"%@amountSpend", documentsDirectory];
[amountSpend writeToFile:fullFileName1 atomically:NO];
No comments:
Post a Comment