本文整理汇总了Python中objc_generator.ObjCGenerator.objc_setter_method_for_member方法的典型用法代码示例。如果您正苦于以下问题:Python ObjCGenerator.objc_setter_method_for_member方法的具体用法?Python ObjCGenerator.objc_setter_method_for_member怎么用?Python ObjCGenerator.objc_setter_method_for_member使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类objc_generator.ObjCGenerator
的用法示例。
在下文中一共展示了ObjCGenerator.objc_setter_method_for_member方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _generate_setter_for_member
# 需要导入模块: from objc_generator import ObjCGenerator [as 别名]
# 或者: from objc_generator.ObjCGenerator import objc_setter_method_for_member [as 别名]
def _generate_setter_for_member(self, domain, declaration, member):
objc_type = ObjCGenerator.objc_type_for_member(declaration, member)
var_name = ObjCGenerator.identifier_to_objc_identifier(member.member_name)
setter_method = ObjCGenerator.objc_setter_method_for_member(declaration, member)
conversion_expression = ObjCGenerator.objc_to_protocol_expression_for_member(declaration, member, var_name)
lines = []
lines.append('- (void)set%s:(%s)%s' % (ucfirst(var_name), objc_type, var_name))
lines.append('{')
lines.append(' [super %s:%s forKey:@"%s"];' % (setter_method, conversion_expression, member.member_name))
lines.append('}')
return '\n'.join(lines)
示例2: _generate_setter_for_member
# 需要导入模块: from objc_generator import ObjCGenerator [as 别名]
# 或者: from objc_generator.ObjCGenerator import objc_setter_method_for_member [as 别名]
def _generate_setter_for_member(self, domain, declaration, member):
objc_type = self.objc_type_for_member(declaration, member)
var_name = ObjCGenerator.identifier_to_objc_identifier(member.member_name)
setter_method = ObjCGenerator.objc_setter_method_for_member(declaration, member)
conversion_expression = self.objc_to_protocol_expression_for_member(declaration, member, var_name)
lines = []
lines.append('- (void)set%s:(%s)%s' % (ucfirst(var_name), objc_type, var_name))
lines.append('{')
objc_array_class = self.objc_class_for_array_type(member.type)
if objc_array_class and objc_array_class.startswith(self.objc_prefix()):
lines.append(' THROW_EXCEPTION_FOR_BAD_TYPE_IN_ARRAY(%s, [%s class]);' % (var_name, objc_array_class))
lines.append(' [super %s:%s forKey:@"%s"];' % (setter_method, conversion_expression, member.member_name))
lines.append('}')
return '\n'.join(lines)