1

我正在开发一个简单的程序,它使用 NSMutableDictionary 作为参数创建 SOAP 消息。我不明白为什么我从其他类调用的 NSMutableDictionary 变量总是返回空值,即使我已经添加了值。我直接尝试了 setObject: forKey 但它也不起作用。

这是我的代码:

SOAPLib.h @property(nonatomic,retain)NSMutableDictionary *parameters;

Calculator.m SOAPLib *createSoap = [[SOAPLib alloc]init];

createSoap.Envelope = @"http://schemas.xmlsoap.org/soap/envelope/";
createSoap.MethodName = @"add";
createSoap.ServiceNameSpace = @"http://calculator.me.org/";

NSMutableDictionary *parameters = [[NSMutableDictionary alloc]init];
[parameters setObject:[NSNumber numberWithInt:2] forKey:@"i"];
[parameters setObject:[NSNumber numberWithInt:3] forKey:@"j"];

NSLog(@"Calc parameters: %@",parameters);  <--- returns i = 2, j = 3

[createSoap.parameters setDictionary:parameters]; <--- set

NSLog(@"create soap param: %@", createSoap.parameters); <--- returns null
4

1 回答 1

1

只需致电:

createSoap.parameters = parameters;

代替

[createSoap.parameters setDictionary:parameters];
于 2013-05-10T08:44:31.257 回答