如何将nsmutable字典中的nsmutable数组的值分配给另一个nsmutable字典或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.
我需要获得 id 和 publicAccess 的价值并分配到另一个NSDictionary。
答案 0 :(得分:0)
试试这个
NSMutableArray *mArray = readers[@"id"];
BOOL publicAccess = readers[@"publicAccess"];
NSNumber *num = [NSNumber numberWithBool: publicAccess];
NSString * result = [mArray componentsJoinedByString:@","]
NSDictionary * data = @{@"readers_ids" :result,@"publicAccess" : num};