インターネット上のファイルの内容を取得する方法は?たとえば、私はNSStringにrssフィードのコンテンツをhttp://news.tut.by/rss/index.rssから取得したいと考えています。どうしたらいいですか?私はiOS SDKクラスだけを使用したい:NSURLConnection、NSURLRequest等 P.S.インターネット上のファイルの内容を取得するには?
#import <Foundation/Foundation.h>
@interface RssDownloader : NSObject {
NSURLConnection * conn;
NSMutableData * receivedData;
}
@property(nonatomic, retain) NSURLConnection * conn;
@property(nonatomic, retain) NSMutableData * receivedData;
- (void)downloadUrlContent : (NSURL *)url;
@end
@implementation RssDownloader
@synthesize receivedData, conn;
- (void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
[receivedData release];
receivedData = nil;
}
- (void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
[receivedData appendData:data];
}
- (void) connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
[connection release];
[receivedData release];
}
- (void) connectionDidFinishLoading:(NSURLConnection *)connection {
[connection release];
[receivedData release];
}
- (void) downloadUrlContent:(NSURL *)url {
NSURLRequest * urlRequest = [[NSURLRequest alloc] initWithURL:url
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
conn = [[NSURLConnection alloc] initWithRequest:urlRequest delegate:self startImmediately:YES];
if (conn) {
receivedData = [[NSMutableData data] retain];
}
}
- (void)dealloc {
[conn release];
[receivedData release];
}
@end
が、それは動作しません:私は、このようなクラスを見ました。
「定義 "が、それは動作しません。" これは私ができる変更した後も – KevinDTimm