PDA

View Full Version : Help with files in simulator




teengohan
May 21, 2011, 12:43 PM
Hi all,

Earlier I was experementing with reading in a .plist file in my app, now I am trying to write code to access this file from a server.

Before I started I had to make sure I was not still accessing a local copy so I deleted the file from the supporting files folder in Xcode and uninstalled the app from the simulator, then to be extra sure I reset the content and settings of the simulator.

The odd thing is that when I run the app now it still reads all the data from the file which should not be the case, my code is below:


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
[window makeKeyAndVisible];
// create a pointer to a dictionary and a temporary dictionary
NSDictionary *dictionary;
NSDictionary *tempDict;

// read "productFeed.plist" from application bundle
NSString *path = [[NSBundle mainBundle] bundlePath];
NSString *finalPath = [path stringByAppendingPathComponent:@"productList.plist"];
dictionary = [NSDictionary dictionaryWithContentsOfFile:finalPath];

// dump the contents of the dictionary to the console
for (id key in dictionary) {
tempDict = [dictionary objectForKey:key];
NSLog(@"Product Name = %@", [tempDict valueForKey:@"name"]);
}

self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}


What it does is read in the plist and output a list of product names from the plist to the console.

All I need to know is how to clear the old .plist file from the simulator, I think I know how to access the plist remotely already but I can't test it untill I know for sure the local file is gone.

Can anyone help me do this?



PhoneyDeveloper
May 21, 2011, 12:56 PM
Do a Clean in Xcode and then rebuild. You may need to also remove the app again from the Sim.

teengohan
May 21, 2011, 01:13 PM
Thanks a lot that worked a treat, as did reading the file remotley :D