6

を使用して次の Web ページを作成したいCocoaHTTPServer: ファイルをダウンロードするためのリンクが必要ですが、ソース ファイルNSDataはメモリ内のオブジェクトである必要があります。

サンプルを見る限り、iPhone 上のファイルをハイパーリンクにリンクする簡単な方法があります。「リンク」はできNSDataますか?

例に非常に感謝します。

4

1 に答える 1

7

必要なことはHTTPDataResponse、HTTPConnection サブクラスで戻ることだけです。

例が必要な場合は、呼び出された CocoaHTTPServer サンプルを見て、次のようなものにDynamicServer置き換え- httpResponseForMethod: URI:てください。MyHTTPConnection

- (NSObject<HTTPResponse> *)httpResponseForMethod:(NSString *)method URI:(NSString *)path
{
    // Before returning you can analyze the passed path argument and select the correct data object to return...
    return [[HTTPDataResponse alloc] initWithData:placeYourDataInstanceHere];
}
于 2012-10-18T16:28:37.650 に答える