Psychs #4019(2007/11/14 13:00 GMT) [ Objective-C ] Rating0/0=0.00
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
#import <Foundation/Foundation.h> #import <Appkit/Appkit.h> @interface AppController : NSObject { NSURLConnection* connection; NSMutableData* buffer; } @end @implementation AppController - (void)dealloc { [connection release]; [buffer release]; [super dealloc]; } - (void)startRequest { buffer = [NSMutableData data]; NSURL* url = [NSURL URLWithString:@"http://ja.doukaku.org/feeds/comments/"]; NSMutableURLRequest* req = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:30.0]; [req setHTTPMethod:@"GET"]; connection = [[NSURLConnection alloc] initWithRequest:req delegate:self]; } - (void)connectionDidFinishLoading:(NSURLConnection*)conn { NSXMLDocument* doc = [[[NSXMLDocument alloc] initWithData:buffer options:0 error:NULL] autorelease]; if (doc) { NSArray* nodes = [doc nodesForXPath:@"//lastBuildDate" error:NULL]; for (id obj in nodes) { NSLog(@"%@", [obj stringValue]); } } [NSApp terminate:self]; } - (void)connection:(NSURLConnection*)conn didFailWithError:(NSError*)err { NSLog(@"error"); [NSApp terminate:self]; } - (void)connection:(NSURLConnection*)conn didReceiveData:(NSData*)data { [buffer appendData:data]; } @end int main(int argc, char** argv) { id pool = [NSAutoreleasePool new]; [NSApplication sharedApplication]; id controller = [[[AppController alloc] init] autorelease]; [controller startRequest]; [NSApp run]; [pool release]; return 0; }
Rating0/0=0.00-0+
[ reply ]
Psychs
#4019()
[
Objective-C
]
Rating0/0=0.00
Rating0/0=0.00-0+
[ reply ]