开发者

Array of Arrays - writing to File problem

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 string开发者_JAVA技巧ByAppendingPathComponent: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?


AFAIK the write to file uses object archiving hence some objects in your array of arrays can't be archived.


Have you got any NSNulls in your arrays anywhere? I don't think they count as plist objects and so would cause the write to fail.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜