Created
September 9, 2011 16:14
-
-
Save rsaunders100/1206638 to your computer and use it in GitHub Desktop.
(iOS) Saves the response of a parsing result to disk and restores it later, for hacking / testing feeds
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)processLoginWithData:(NSData*)data { | |
// | |
// Pull the data in from disk | |
// | |
NSString* responsePath = [[NSBundle mainBundle] pathForResource:@"response" ofType:@"xml"]; | |
NSString* hackedString = [NSString stringWithContentsOfFile:responsePath | |
encoding:NSUTF8StringEncoding | |
error:nil]; | |
data = [hackedString dataUsingEncoding:NSUTF8StringEncoding]; | |
TBXML * loginXml = [TBXML tbxmlWithXMLData:data]; | |
NSString* xml = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; | |
NSLog(@"%@", xml); | |
// | |
// Save the resonse to disk | |
// | |
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); | |
NSString *docsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; | |
NSString *path = [docsDirectory stringByAppendingPathComponent:@"response.xml"]; | |
NSError* error = nil; | |
[xml writeToFile:path | |
atomically:NO | |
encoding:NSUTF8StringEncoding | |
error:&error]; | |
NSLog(@"FILE PATH:%@", path); | |
// Continue parsing... | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment