Array of Arrays - writing to File problem

Posted by iFloh on Stack Overflow See other posts from Stack Overflow or by iFloh
Published on 2010-05-20T04:53:55Z Indexed on 2010/05/20 5:30 UTC
Read the original article Hit count: 206

Filed under:
|
|

Hi, and again my array of arrays ... I try to improve my app performance by buffering arrays on file for later reuse.

I have an NSMutableArray that contains about 30 NSMutableArrays with NSNumber, NSDate and NSString Objects.

I try to write the file using this call:

bool result = [myArray writeToFile:[fileMethods 
                                    getFullPath:[NSString 
                                                 stringWithFormat:@"iEts%@.arr", 
                                                 [aDate shortDateString]]] 
                       atomically:NO];

=> result = FALSE.

The Path method is:

+ (NSString *) getFullPath:(NSString *)forFileName {
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    return [documentsDirectory stringByAppendingPathComponent:forFileName];
}

and the aDate call returns a shortDateString with ddMMyy.

The NSLog

NSLog(@"%@", [fileMethods getFullPath:[NSString stringWithFormat:@"iEts%@.arr", 
                                                [aDate shortDateString]]]);

on the path generation returns:

/Users/me/Library/Application Support/iPhone Simulator/User/Applications/86729620-EC1D-4C10-A799-0C638BB27933/Documents/iEts010510.arr

FURTHER:

  • It must have something to do with the Array of Arrays, since I also write 3 further simple arrays (containing NSStrings) that all succeed.
  • The Array of Arrays gets generated using the addObject method

Any ideas what could cause the trouble?

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about iphone