There is an attribute in my Core Data document-based app whose string value can legitimately be a single single utf8 0x20 space character, @" ". (It's a user-selectable delimiter.)

When I save a document with this attribute value, reading the XML store file with BBEdit shows that it is a single space character, like this:

   <attribute name="firstname" type="string"> </attribute>

But it shows up as an empty string in the user interface when my app loads the document. I inserted a manually-coded getter and found that it's coming out of the moc this way, although if I re-type it to become a single space again, it comes out of the moc as expected, " ", until I close and re-open the document. Then it's back to an empty string, "".

This is easily reproducible in DepartmentAndEmployees sample project. In the app Target, set the document Store Type to XML. Add an employee, type in firstName " ", save, re-open, and the name is changed to "". Same thing if the name is more than one space, such as " ". However, it does not "trim" whitespace; for example, " Jerry " is read as expected, with spaces on each end.

Add this code [1] to the Employee implementation to see the primitive value.

If you use the sqlite store, it behaves ^I^ expect, properly reading the one-character string. Of course, my app will ship with the sqlite store but I need to know which behavior is expected and which behavior is a bug, or if it is expected that the xml behave differently than the sqlite, why?

Thanks as always,

Jerry Krinock


[1]
- (NSString *)firstName  {
    NSString * tmpValue ;

    [self willAccessValueForKey:@"firstName"];
    tmpValue = [self primitiveFirstName];
        NSLog(@"primitive firstName = \"%...@\"", tmpValue) ;
    [self didAccessValueForKey:@"firstName"];

    return tmpValue;
}

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to