ios - Value Expression during Core Data migration causing unusual result -


i have ios app core data model i'm trying migrate new version.

there 1 new field (photofilename) in v2 of core data model, , it's value can generated existing entries using v1 field (dateinseconds) , appending '.jpg'.

for example

version 1                               | version 2 field          data                     | field          data ========================================|============================== dateinseconds (integer 32)  401760341   | dateinseconds (integer 32)  401760341                                         | photofilename (string)  401760341.jpg  

i have created core data mapping model (partially shown below), , database appears migrate. unfortunately, photofilename created not give correct number in front of '.jpg'. example, might return '275263312.jpg' instead of '401760341.jpg'

enter image description here

now admittedly, i've never used such mapping before , apple documentation here seems limited.

researching elsewhere appears the 'value expression' type of nsexpression , can replicated testing purposes.

nsexpression *expr = [nsexpression expressionwithformat:@"function('', 'stringbyappendingformat:', '%d.jpg', 401760341)"]; id result = [expr expressionvaluewithobject:nil context:nil]; nslog(@"result: %@", result); 

however, evaluates incorrect number in front of '.jpg'.

can point out why evaluated result obtained not expected result?

i'm still not sure exact cause of problem, came across following work around in mapping model casting nsstring

enter image description here

or of following along using nsexpression

nsexpression *expr = [nsexpression expressionwithformat:@"function('', 'stringbyappendingformat:', '%@.jpg', cast(401760341, 'nsstring') )"]; id result = [expr expressionvaluewithobject:nil context:nil]; nslog(@"result: %@", result); 

Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -