This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NSURL * serverUrl = [ NSURL URLWithString : @ "http://ATTACKER/SJ_headlines.json" ] ; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - ( void ) fetchArticles | |
| { | |
| NSURL * serverUrl = [ NSURL URLWithString : @ "http://skycure-journal.herokuapp.com" ] ; | |
| NSMutableURLRequest * request = [ NSMutableURLRequest requestWithURL : serverUrl ] ; | |
| [ request setValue : @ "application/json" forHTTPHeaderField : @ "Content-Type" ] ; | |
| self.connection = [ [ NSURLConnection alloc ] initWithRequest : request delegate : self ] ; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @interface HRHResistantURLCache : NSURLCache | |
| @end | |
| @implementation HRHResistantURLCache | |
| - (void)storeCachedResponse:(NSCachedURLResponse *)cachedResponse | |
| forRequest:(NSURLRequest *)request | |
| { | |
| if (301 == [(NSHTTPURLResponse *)cachedResponse.response statusCode]) { | |
| return; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #define DEFAULT_MEMORY_CAPACITY 512000 | |
| #define DEFAULT_DISK_CAPACITY 10000000 | |
| HRHResistantURLCache *myCache = [HRHResistantURLCache alloc]; | |
| [myCache initWithMemoryCapacity:DEFAULT_MEMORY_CAPACITY | |
| diskCapacity:DEFAULT_DISK_CAPACITY | |
| diskPath:@"MyCache.db"]; | |
| [NSURLCache setSharedURLCache:myCache]; |