參數傳遞給WCF服務在目標C我有接受這樣的參數WCF服務:通行證對象在iOS
[DataContract]
public class Person
{
[DataMember]
public int ID { get; set; }
[DataMember]
public string Name { get; set; }
[DataMember]
public string Family { get; set; }
}
[OperationContract]
[WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json, UriTemplate = "")]
int InsertPerson(Person person);
我熟悉如何消費與Objective-字符串參數的WCF服務C但在這種情況下,我想傳遞一個Person類的實例作爲參數。我怎樣才能做到這一點?
NSString *path = [[NSString alloc] initWithFormat:@"http://192.168.0.217/JSON/Service1.svc/InsertPerson"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:path]];
[request setHTTPMethod:@"POST"];
[[NSURLConnection alloc] initWithRequest:request delegate:self];
我知道這是舊的,但,在JSONRepresentation線給我這個錯誤**「對的NSMutableDictionary沒有可見的接口聲明的選擇JSONRepresentation」 ** – gdubs
敬請期待在這[SO回答](http://stackoverflow.com/questions/7143863/jsonrepresentation-for-nsmutabledictionary?answertab=votes#tab-top)看哪些是適當的庫包括。 –
包含SBJson庫以使用JSONRepresentation。你可以從https://github.com/stig/json-framework得到它 – Dilip