Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

sujithkrishnan

macrumors 6502
Original poster
May 9, 2008
265
0
Bangalore
In my iPhoneApp ,

I am archiving an object for the first run, using the archived object from next run..
But my application returning NO for variable success for the code below in device, however in simulator, its returning YES and unarchiving the file to retrieve values...

Code:
NSFileManager *fileManager = [NSFileManager defaultManager];
	NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
	NSString *documentsDirectory = [paths objectAtIndex:0];
	NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:@"customerInfo.xml"];
	BOOL success = [fileManager fileExistsAtPath:writableDBPath];
	
	
	if(success == YES)
	{
		CustomerInfo *cobj;
		cobj = [NSKeyedUnarchiver unarchiveObjectWithFile:writableDBPath];
		[CustomerInfo setCustomerObject:cobj];
	}

Archiving (which is returning YES both in device and simulator....)
Code:
NSFileManager *fileManager = [NSFileManager defaultManager];
				NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
				NSString *documentsDirectory = [paths objectAtIndex:0];
				NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:@"CustomerInfo.xml"];
				BOOL success = [NSKeyedArchiver archiveRootObject:[CustomerInfo getCustomerObject] toFile:writableDBPath];
One thing which is strange that its returning YES for the archiving part both in device and simulator.

IN DEVICE....
If i am archiving and checking for the file suddenly, its showing "FILE IS THERE"...means archiving the file returns YES... My question is eventhough the file is not archived properly, whether the archive function return "YES" ??


I am saving the file in doc.directory...
I am doing same kind of archiving for another BIG object, but its working fine with simulator and device...
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.