我正在开发一个简单的程序,它使用NSMutableDictionary为参数创建SOAP消息。我不明白为什么我从其他类调用的NSMutableDictionary变量总是返回null值,即使我已经添加了值。我直接尝试了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
答案 0 :(得分:1)
请致电:
createSoap.parameters = parameters;
而不是
[createSoap.parameters setDictionary:parameters];