ios – 核心数据关系映射:值表达式中的双引号自动转换为单引号

在为核心数据迁移生成映射模型之后,正确生成关系映射的所有值表达式,除了1值表达式,其中参数具有单引号(‘)而不是双引号(“).这会导致解析错误.

这就是我所期望的:

FUNCTION($manager ,"destinationInstancesForEntityMappingNamed:sourceInstances:" , "MatchToMatch" , $source.matches)

但这是函数表达式的生成方式:

FUNCTION($manager ,'destinationInstancesForEntityMappingNamed:sourceInstances:' , 'MatchToMatch' , $source.matches)

A specific Value Expression is always generated with single quotes

当我将右侧边栏中的“Source Fetch”选项更改为“Use Custom(…)”并手动输入表达式时,所有双引号都会变回单引号.

当我在Mapping Editor表中直接更改Value Expression时,收到以下错误消息:

Unable to parse the format string “FUNCTION($manager >,”destinationInstancesForEntityMappingNamed:sourceInstances:” , >”MatchToMatch” , $source.matches) == 1″

当我构建并运行迁移时,我收到以下错误消息:

2016-01-27 10:30:33.875 mapc[1431:352140] *** Terminating app due to >uncaught exception ‘NSInvalidArgumentException’, reason: ‘Unable to parse >the format string “FUNCTION($manager >,’destinationInstancesForEntityMappingNamed:sourceInstances:’ , >’MatchToMatch’ , $source.matches) == 1″‘

有人可以解释一下,发生了什么以及如何解决这个问题?

最佳答案 这里的问题是匹配是一个保留关键字.

保留关键字:
https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/Predicates/Articles/pSyntax.html

查看此处描述的注释:
https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CoreDataVersioning/Articles/vmMappingOverview.html

点赞