1

我使用 Delphi XE2 (Firemonkey) 编写了一个 iOS 应用程序来调用 web 服务。

自从我应用 Delphi XE2 Update 2 以来,代码已停止编译 - (以前我使用的是 update 1)。我还将 XCode 更新到 4.2 和 iOS5,但是我认为从那时起编译还可以(不是 100% 肯定)。所以我不能自信地将其排除为嫌疑人。

这是之前使用 FPC 在 xcode 下编译好的代码片段(并且工作得很好!)。我已经在 mac 上应用了 FPC 和 Firemonkey XE2 更新。

TSynWebServices_iOS = objcclass(NSURLConnection)
private
  reqURL:     NSURL;
  reqPacket:  NSMutableURLRequest;
  webData:    NSMutableData;
public
  function  init: id; override;
  procedure dealloc; override;
  //
  procedure connection_didReceiveResponse(connection: NSURLConnection;
                                          response: NSURLResponse); override;
  procedure connection_didReceiveData(connection: NSURLConnection; data: NSData); override;
  procedure connection_didFailWithError(connection: NSURLConnection; error: NSError); override;
  procedure connectionDidFinishLoading(connection: NSURLConnection); override;
end;

现在我收到以下错误...

SynWebServices_iOS_Unit.pas(44,15) Error: There is no method in an ancestor class to be overridden: "TSynWebServices_iOS.connection_didReceiveResponse(NSURLConnection,NSURLResponse);"
SynWebServices_iOS_Unit.pas(46,15) Error: There is no method in an ancestor class to be overridden: "TSynWebServices_iOS.connection_didReceiveData(NSURLConnection,NSData);"
SynWebServices_iOS_Unit.pas(47,15) Error: There is no method in an ancestor class to be overridden: "TSynWebServices_iOS.connection_didFailWithError(NSURLConnection,NSError);"
SynWebServices_iOS_Unit.pas(48,15) Error: There is no method in an ancestor class to be overridden: "TSynWebServices_iOS.connectionDidFinishLoading(NSURLConnection);"
SynWebServices_iOS_Unit.pas(44,15) Error: Objective-C messages require their Objective-C selector name to be specified using the "message" directive.
SynWebServices_iOS_Unit.pas(44,15) Error: Mismatch between number of declared parameters and number of colons in message string.
SynWebServices_iOS_Unit.pas(46,15) Error: Mismatch between number of declared parameters and number of colons in message string.
SynWebServices_iOS_Unit.pas(47,15) Error: Mismatch between number of declared parameters and number of colons in message string.
SynWebServices_iOS_Unit.pas(48,15) Error: Mismatch between number of declared parameters and number of colons in message string.
SynWebServices_iOS_Unit.pas(56,1) Fatal: There were 9 errors compiling module, stopping
Fatal: Compilation aborted

查看似乎是 FPC 的包含文件 - 'NSURLConnection.inc' - 这些方法不是为 NSURLConnection 定义的,但是它们是为类 NSURLConnectionDelegateCategory 定义的。

但是,如果我尝试从 NSURLConnectionDelegateCategory 继承,则无法识别该类。

有没有其他人遇到过这个问题,或者设法在 XE2 更新 2 下使用 NSURLConnection?

谢谢

4

1 回答 1

0

这个问题已经在这里回答了......(方法已经移动)

https://forums.codegear.com/thread.jspa?threadID=63537&tstart=0

于 2011-11-05T21:17:12.180 回答