JSONModelを使い始めたばかりです。JSONHTTPClient は、「GET」および「POST」メソッドをサポートする非同期ネットワーク リクエストを処理できます。JSONHTTPClient を使用して「PUT」または「DELETE」リクエストを行う方法はありますか?
2 に答える
0
とにかく、JSONHTTPClient に新しいメソッドを追加することで、最もばかげた解決策を見つけました。
+(void)putJSONFromURLWithString:(NSString)urlString params:(NSDictionary)params completion:(JSONObjectBlock)completeBlock;
+(void)putJSONFromURLWithString:(NSString)urlString bodyString:(NSString)bodyString completion:(JSONObjectBlock)completeBlock;
+(void)putJSONFromURLWithString:(NSString)urlString bodyData:(NSData)bodyData completion:(JSONObjectBlock)completeBlock;
「PUT」をサポートするために新しい const NSString も追加しました
NSString* const kHTTPMethodPUT = @"PUT";
+(void)putJSONFromURLWithString:(NSString*)urlString params:(NSDictionary*)params completion:(JSONObjectBlock)completeBlock
{
[self JSONFromURLWithString:urlString method:kHTTPMethodPUT
params:params
orBodyString:nil completion:^(id json, JSONModelError* e) {
if (completeBlock) completeBlock(json, e);
}];
}
+(void)putJSONFromURLWithString:(NSString*)urlString bodyString:(NSString*)bodyString completion:(JSONObjectBlock)completeBlock
{
[self JSONFromURLWithString:urlString method:kHTTPMethodPUT
params:nil
orBodyString:bodyString completion:^(id json, JSONModelError* e) {
if (completeBlock) completeBlock(json, e);
}];
}
+(void)putJSONFromURLWithString:(NSString*)urlString bodyData:(NSData*)bodyData completion:(JSONObjectBlock)completeBlock
{
[self JSONFromURLWithString:urlString method:kHTTPMethodPUT
params:nil
orBodyString:[[NSString alloc] initWithData:bodyData encoding:defaultTextEncoding]
completion:^(id json, JSONModelError* e) {
if (completeBlock) completeBlock(json, e);
}];
}
また、 GitHubで問題を作成しました。そこからの反応を期待します。
于 2015-03-18T11:04:11.603 に答える