【发布时间】:2010-02-22 06:44:10
【问题描述】:
我正在尝试使用 NSURLDownload 下载 URL,但它没有开始下载。在继续之前,必须说我正在为此使用 GNUStep。
我的项目大纲如下:
MyClass.h:
@interface MyClass : Object {
}
-(void)downloadDidBegin:(NSURLDownload*)download;
-(void)downloadDidFinish:(NSURLDownload*)download;
@end
Main.m
int main()
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
NSLog(@"creating url");
NSURL* url = [[[NSURL alloc] initWithString:@"http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSURLRequest_Class/NSURLRequest_Class.pdf"] autorelease];
NSLog(@"creating url request");
NSURLRequest* url_request = [[[NSURLRequest alloc] initWithURL:url] autorelease];
NSLog(@"creating MyClass instance");
MyClass* my_class = [[MyClass alloc] init];
NSLog(@"creating url download");
NSURLDownload* url_download = [[[NSURLDownload alloc] initWithRequest:url_request
delegate:my_class] autorelease];
[pool drain];
}
我在 MyClass 中的两个函数上都有 NSLog,但它们都没有被命中。我必须做什么才能开始下载?或者这是 GNUStep 的问题?
【问题讨论】:
-
您确定要继承 Object 而不是 NSObject?您可能应该使用 NSObject,以防万一某些东西将您的委托放入集合或其他东西中。 (另外,你真的应该想一个比“MyClass”更好的名字,并通过遵循内存管理规则来适当地管理对象的生命周期:developer.apple.com/mac/library/documentation/General/…)
标签: objective-c cocoa gnustep