1
我正在開發一個簡單的程序,它使用NSMutableDictionary爲參數創建SOAP消息。我不明白爲什麼從其他類調用的NSMutableDictionary變量總是返回空值,即使我已經添加了值。我直接嘗試了setObject:forKey,但它也不起作用。NSMutableDictionary始終爲空
這是我的代碼:
SOAPLib.h @屬性(非原子,保留)的NSMutableDictionary *參數;
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
我應該在哪裏初始化的SOAPLib.m或Calculator.m?如果在SOAPLib.m中,它沒有viewDidLoad,因爲我把它作爲一個庫。我怎麼可能做到這一點? – MAC 2013-05-10 08:48:22
我建議的所有更改都將在Calculator.m中進行。 – robbartoszewski 2013-05-10 08:54:08
我已經嘗試過,然後再回復它,但無論如何感謝.. – MAC 2013-05-10 08:58:47