i ran problem , can't find method on it. need make mutable dictionary values. values dynamic , them web service or other variables.
nsmutabledictionary *dict = [[nsmutabledictionary alloc] init]; [dict setobject:comment.text forkey:@"comment"]; [dict setobject:name.text forkey:@"name"]; [dict setobject:[nsstring stringwithformat:@"%d",ispublic] forkey:@"visibleforall"]; po dict { comment = "no comment"; name = "test"; visibleforall = 1; -> carts } furthermore want add following tree dictionary can't figure how this.
i have necessary items in 2 nsarray artid , qty don't know how create bottom part can add dict.
carts { cart { articleid : 22 quantity : 1 } cart { articleid : 45 quantity : 3 } ... } i add [dict setobject:carts forkey:@"cart"] don't know how add values in such manner make dictionary on form presented you.
also, don't forget numbers or carts flexible. product.count.
thanks in advance.
if both array artid , qty have value @ same index create dictionary can try this
nsmutablearray *carts = [[nsmutablearray alloc] init]; for(nsinteger i=0; i<products.count; i++) { //if have custom class `cart` use cart *cart = [[cart alloc] init]; cart.articleid = [[products objectatindex:i] valueforkey:@"pid"]; cart.quantity = [[products objectatindex:i] valueforkey:@"qty"]; //if not have custom class use dictionary nsmutabledictionary *cart = [[nsmutabledictionary alloc] init]; [cart setobject:[[products objectatindex:i] valueforkey:@"pid"] forkey:@"articleid"]; [cart setobject:[[products objectatindex:i] valueforkey:@"pid"] forkey:@"quantity"]; } now add carts array dictionary key
[dict setobject:carts forkey:@"carts"];
Comments
Post a Comment