-
-
Notifications
You must be signed in to change notification settings - Fork 75
Methods setting values
List and types of methods available in the framework to set the values to be post to the service.
Method name | Type |
---|---|
setDoubleValue | double |
setFloatValue | float |
setImage | UIImage |
setIntegerValue | NSInteger |
setLongValue | long |
setValue | NSObject |
All methods require as input, in addition to the value, the name of the html tag for that value:
[soap setDoubleValue:0 forKey:"tag-name"];
The setValue
method accepts as input any type of value, even complex objects such as NSDictionary or NSSet, or custom objects derived from NSObject:
@interface MyObject: NSObject {
@property (strong) NSString* value;
@property (string) NSDictionary* dict;
}
MyObject object = [[MyObject alloc] init];
object.value = "123";
[soap setValue:object forKey:"tag-name"];
The setValue
method also has more extensive parameters for defining attributes and sub-keys. An example to generate an html tag called text
with value ABCD
and that has an attribute xmlns
with value http://tempuri.org
:
NSDictionary *attr = @{"xmlns" : "http://tempuri.org"};
[soap setValue:"ABCD" forKey:"text" attributes:attr];
this will generate an xml similar to this below:
<text xmlns="http://tempuri.org">ABCD</text>
instead for a subkey:
[soap setValue:"ABCD" forKey:"text" subKeyName:"value"];
this will generate an xml similar to this below:
<text><value>ABCD</value></text>
here is a more complex example with dictionary:
NSArray *param3 = @[
@{@"description": @"i am a description"},
@{@"name": @"i am a name"},
@{@"subdata": @{
@"name": @"i am a name too",
@"profession": @"worker"
}
},
@{@"subdata": @{
@"name": @"just another name",
@"profession": @"worker"
}
}
];
[soap setValue:param3 forKey:@"param3"];
or with a custom object:
@interface MySubData : NSObject {
NSString *name;
NSString *profession;
};
@end
@interface MyData : NSObject {
NSString *description;
NSString *name;
NSArray<MySubData*> *subdata;
};
@end
MyData *object = [[MyData alloc] init];
//
// your code here...
//
soap.defaultTagName = nil;
[soap setValue: object forKey: @"param3"];
this will generate an xml similar to this below:
<param3>
<description>i am a description</description>
<name>i am a name</name>
<subdata>
<name>i am a name too</name>
<profession>worker</profession>
</subdata>
<subdata>
<name>just another name</name>
<profession>worker</profession>
</subdata>
</param3>