HXHG
Jump To… Overview Tasks - initWithCustomDictionary: - addObjectValue:forKey: - addStringValue:forKey: - addNumberValue:forKey: - setContentText:
# JMSGCustomContent Class Reference
Inherits from | JMSGAbstractContent : NSObject |
Conforms to | NSCopying |
Declared in | JMSGCustomContent.h |
## Overview
定制内容类型
用于自定义消息的内容类型.
建议只在基本类型 (TextContent, VoiceContent, ImageContent) 不满足使用的情况才使用此类型.
所有的内容类型都带有 extras 可附加字段信息, 从而都具备一定的定制能力. 比如如果需要基于图片做简单定制, 建议基于 ImageContent 再附加 extra 的方式.
### – initWithCustomDictionary:
预期使用的初始化方法
- (instancetype)initWithCustomDictionary:(NSDictionary *JMSG_NULLABLE)customDict
#### Parameters
#### Declared In
JMSGCustomContent.h
### – addObjectValue:forKey:
添加一个键值对.
- (BOOL)addObjectValue:(NSObject *)value forKey:(NSString *)key
#### Parameters
value |
值. 必须满足 JSON Value 的要求, 基本规则是: NSNumber, NSString, NSArray, NSDictionary
|
key |
键
|
#### Return Value
如果无效的 value, 返回 false, 添加失败
#### Discussion
value的有效性校验, 参考 Apple 官方文档: https://developer.apple.com/library//ios/documentation/Foundation/Reference/NSJSONSerialization_Class/index.html#//apple_ref/occ/clm/NSJSONSerialization/isValidJSONObject:
#### Declared In
JMSGCustomContent.h
### – addStringValue:forKey:
快捷添加 String 类型 value 的方法
- (BOOL)addStringValue:(NSString *)value forKey:(NSString *)key
#### Parameters
value |
键值对里的值. String 类型.
|
key |
键值对里的键
|
#### Return Value
如果无效的 value, 返回 false, 添加失败
#### Declared In
JMSGCustomContent.h
### – addNumberValue:forKey:
快捷添加 Number 类型 value 的方法
- (BOOL)addNumberValue:(NSNumber *)value forKey:(NSString *)key
#### Parameters
value |
键值对里的值. Number 类型.
|
key |
键值对里的键
|
#### Return Value
如果无效的 value, 返回 false, 添加失败
#### Declared In
JMSGCustomContent.h
### – setContentText:
设置该自定义消息内容的文本描述
- (void)setContentText:(NSString *)contentText
#### Parameters
#### Discussion
用于展示在会话列表, 文本地简要描述这条消息. 如果未设置, 则默认值为 “[自定义消息]”
#### Declared In
JMSGCustomContent.h
Copyright © 2019 HXHG. All rights reserved. Updated: 2019-05-06
Generated by appledoc 2.2.1 (build 1334).