-2

How can i assign value of nsmutable array which is inside of nsmutable dictionary into another nsmutable dictionary or NSDictionary?

  NSMutableDictionary *readers = [[NSMutableDictionary alloc] init];
[readers setObject:[[NSMutableArray alloc] init] forKey:@"id"];
readers[@"publicAccess"] = @NO;



// Create dictionary of parameters to be passed with the request
NSDictionary *data = @{
     // @"reader_ids": [NSString  stringWithFormat:@"%@",[readers[@"id"]componentsJoinedByString:@","]],

                       };

 NSDictionary *data = @{
     @"reader_ids": // i need here values of "id" as string which is separated by comma since  **reader_ids** is string property and id is MSMutable Array which contains datas.

I need to get value of both id and publicAccess and assign into another NSDictionary.

Jan
  • 1,744
  • 3
  • 23
  • 38
  • You explanation is not enough. you can get back the object for id and publicAccess by using objectForKey method of NSMutableDictionary. – Suhail kalathil Jul 04 '14 at 06:40
  • i need to assign value of id and publicAccess property of NSMutable dictionary into another NSDicationary – Jan Jul 04 '14 at 06:43
  • use [[NSMutableArray alloc] initwitharray:YourArray] –  Jul 04 '14 at 06:44

1 Answers1

0

Try this

 NSMutableArray *mArray = readers[@"id"];
    BOOL publicAccess = readers[@"publicAccess"];
NSNumber *num = [NSNumber numberWithBool: publicAccess];

NSString * result = [mArray componentsJoinedByString:@","]
     NSDictionary * data = @{@"readers_ids" :result,@"publicAccess" : num}; 
Suhail kalathil
  • 2,673
  • 1
  • 13
  • 12
  • 1
    Why not use the new Objective-C dictionary literal syntax? – trojanfoe Jul 04 '14 at 06:50
  • I've got an error like "collection object of type BOOL is not an objective-c object" when i try this method about "publicAccess" in line NSDictionary * newDictionary = @{@"id" :mArray,@"publicAccess" : publicAccess}; – Jan Jul 04 '14 at 07:07
  • is it ok for ur requirement.if ok.pls do the tickmark – Suhail kalathil Jul 04 '14 at 07:19