Search code examples
objective-cxcodecocoaxcode4xcode4.3

xCode 4.3 keeps results in cache


I am developing project in xCode 4.3 for Mac. Lately I have purchased new Mac with Lion, but before I have worked on Snow Leopard. My application connects to server and reads the file off the server and application runs according to what was displayed in the file. The server however is the same machine where the application is running, so I connect with url calling either "localhost" or LAN IP. I have no problem with connection whatsoever. The problem is when I change results in the file. X Code somehow remembers old results from few hours ago. I cleaned application files from Product drop down menu in Xcode, I went to ~/Library/Developer/XCode/DerivedData and manually removed everything there and also opened the Organizer and deleted files from there. I believe they all do the same, however when I re-run application the result shown from server file is still old - unchanged. I call, this particular server file, from web browser and it is up to date - changed the way it should be. Xcode must keep the results of this file somewhere hidden. What step should I make to force Xcode reading files directly and not storing them somewhere? BTW on Snow Leopard it worked perfectly fine with Xcode 4.1.


Solution

  • Instead of getting your XML string from the server using something like "[NSString initWithContentsOfURL:], try doing this:

    NSData* data = [[NSData alloc] initWithContentsOfURL:url options:NSUncachedRead error:&error];
    NSString *dataFromInternet = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
    

    the answer for which I found by looking at this closely related question.

    The important thing is the "NSUncachedRead" bit in the options.