How to make this app not to get the cached information by default every time is opened?
How to make that app reloads every time it opens, and if not internet connection, use the cache?
Actually the app :
if first time opened: it loads from a url... but if it has been already opened, it continue oppening from a cached part....
the problem is that the original file changes and is been updated continuessly so开发者_StackOverflow社区, user gets old information and not the latest one....
what i want is that: 1st time opened, loads from url, all the other times, load from url. but if not internet connection, use the cached information.
Please find the actual code,
if([DreamsUtil isNetworkAvailable]) {
NSData *tempData = [[EGOCache currentCache] dataForKey:DREAMS_CACHE_KEY];
if(tempData != nil)
{
[self parseData:tempData];
}else{
loading = [LoadingView loadingViewInView:self.view];
NSURL *url = [NSURL URLWithString:[DreamsUtil serviceURL]];
// Create the request.
request=[NSURLRequest requestWithURL:url
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60];
connection=[[NSURLConnection alloc] initWithRequest:request delegate:self];
if (connection) {
receivedData = [[NSMutableData data] retain];
dataArray = [NSArray array];
} else {
[DreamsUtil alertWithMessage:@"Connection Faild"];
}//else
}//else
}//if
}
Write some code in applicationDidBecomeActive of AppDelegate. This method is called every time application comes to foreground. Check if you can load new data, if you can't then simply return and let the normal flow show the old results. If you can then refresh the results.
精彩评论