Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // ViewController.m
- // konyvtarAlk
- //
- // Created by Admin on 2014.05.07..
- // Copyright (c) 2014 __MyCompanyName__. All rights reserved.
- //
- #import "ViewController.h"
- @interface ViewController ()
- @end
- @implementation ViewController
- @synthesize inputTitleField;
- @synthesize inputNameField;
- @synthesize messages;
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- // Do any additional setup after loading the view, typically from a nib.
- // szerző, könyvcím, kiadás éve (author, title, date)
- inputNameField.text = @"";
- post = @"command=<SelectDatabase id=\"ekfkdb\"/>";
- postData = [post dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
- postLength = [NSString stringWithFormat:@"%d", [postData length]];
- request = [[NSMutableURLRequest alloc] init];
- [request setURL:[NSURL URLWithString:@"http://m.corvina.ektf.hu"]];
- [request setHTTPMethod:@"POST"];
- [request setValue:postLength forHTTPHeaderField:@"Content-Length"];
- [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
- [request setHTTPBody:postData];
- error = nil;
- response = nil;
- data = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
- NSLog(@"%@",request);
- if (error) {
- NSLog(@"Error:%@", error.localizedDescription);
- }
- else {
- mywebdata=[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
- [outputview loadHTMLString:mywebdata baseURL:nil];
- NSLog(@"%@", mywebdata); // működik
- }
- }
- -(void)search
- {
- post = [[NSString alloc] initWithFormat:@"command=<SelectObj objClasses=\"corvina.obj.MarcData\" xmlForm=\"TypeName\"><And><AttributeFilter attribute=\"Author_name\" term=\"%@\"/><AttributeFilter attribute=\"Title\" term=\"%@\"/></And><Obj class=\"corvina.obj.CatRecordInfo_Bibl\"/></SelectObj>", inputNameField.text, inputTitleField.text];
- NSLog(@"\n\n%@\n\n", post);
- postData = [post dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
- postLength = [NSString stringWithFormat:@"%d", [postData length]];
- request = [[NSMutableURLRequest alloc] init];
- [request setURL:[NSURL URLWithString:@"http://m.corvina.ektf.hu"]];
- [request setHTTPMethod:@"POST"];
- [request setValue:postLength forHTTPHeaderField:@"Content-Length"];
- [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
- [request setHTTPBody:postData];
- error = nil;
- response = nil;
- data = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
- NSLog(@"%@",request);
- if (error) {
- NSLog(@"Error:%@", error.localizedDescription);
- }
- else {
- mywebdata=[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
- [outputview loadHTMLString:mywebdata baseURL:nil];
- NSLog(@"%@", mywebdata); // műkö
- [self messageReceived:mywebdata];
- }
- }
- -(void)messageReceived:(NSString *)message
- {
- parser=[[NSXMLParser alloc] initWithData:[message dataUsingEncoding:NSUTF8StringEncoding]];
- parser.delegate=self;
- [parser parse];
- }
- - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict
- {
- if ([elementName isEqualToString:@"CatRecordInfo_Bibl"])
- {
- }
- }
- - (void)viewDidUnload
- {
- [super viewDidUnload];
- // Release any retained subviews of the main view.
- }
- - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
- {
- return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment