更新时间 : 2021-02-22 09:30:50
替换方法需要根据规范组织参数内容,请先点击以下链接了解
-(void)setReplaceableJson:(NSString *)replaceJson;
调用此接口可以完成 setReplaceableFilePaths 接口的功能,所以不能重复调用。
同 setReplaceableFilePaths 一样,需要在commit前调用。
NSMutableArray *files = [NSMutableArray array];
[files addObject: @{@"main_file" : [[NSBundle mainBundle].resourcePath stringByAppendingPathComponent:@"1.png"],
@"replaces": @[@{@"d_key_prefix": @"dtext",
@"type": @(2),
@"text": @"描述",
}]}];
[files addObject:@{@"replaces": @[@{@"d_key": @"title",
@"type": @(1),
@"file": [[NSBundle mainBundle].resourcePath stringByAppendingPathComponent:@"text.png"]
}]}];
[files addObject:@{@"replaces": @[@{@"d_key": @"brief",
@"type": @(2),
@"text": @"文字精确替换,共三行,居左显示,相册简介"
}]}];
[files addObject:@{@"replaces": @[@{@"d_key": @"summary",
@"type": @(2),
@"text": @"文字精确替换,共三行,居中显示,相册描述"
}]}];
[files addObject:@{@"replaces": @[@{@"d_key": @"endbrief",
@"type": @(2),
@"text": @"文字精确替换,共三行,居右显示,相册鸣谢"
}]}];
NSData *data = [NSJSONSerialization dataWithJSONObject:files options:0 error:nil];
[_mTemplate setReplaceableJson:[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]];
[_mTemplate commit];
替换方法需要根据规范组织参数内容,请先点击以下链接了解
-(void)setReplaceableJson:(NSString *)replaceJson;
调用此接口可以完成 setReplaceableFilePaths 接口的功能,所以不能重复调用。
同 setReplaceableFilePaths 一样,需要在commit前调用。
NSMutableArray *files = [NSMutableArray array];
[files addObject: @{@"main_file" : [[NSBundle mainBundle].resourcePath stringByAppendingPathComponent:@"1.png"],
@"replaces": @[@{@"d_key_prefix": @"dtext",
@"type": @(2),
@"text": @"描述",
}]}];
[files addObject:@{@"replaces": @[@{@"d_key": @"title",
@"type": @(1),
@"file": [[NSBundle mainBundle].resourcePath stringByAppendingPathComponent:@"text.png"]
}]}];
[files addObject:@{@"replaces": @[@{@"d_key": @"brief",
@"type": @(2),
@"text": @"文字精确替换,共三行,居左显示,相册简介"
}]}];
[files addObject:@{@"replaces": @[@{@"d_key": @"summary",
@"type": @(2),
@"text": @"文字精确替换,共三行,居中显示,相册描述"
}]}];
[files addObject:@{@"replaces": @[@{@"d_key": @"endbrief",
@"type": @(2),
@"text": @"文字精确替换,共三行,居右显示,相册鸣谢"
}]}];
NSData *data = [NSJSONSerialization dataWithJSONObject:files options:0 error:nil];
[_mTemplate setReplaceableJson:[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]];
[_mTemplate commit];