iPhone Core Data problem

Posted by Junior B. on Stack Overflow See other posts from Stack Overflow or by Junior B.
Published on 2010-05-10T22:25:25Z Indexed on 2010/05/17 20:20 UTC
Read the original article Hit count: 341

Filed under:
|

This is my first project with Core Data, I followed the Event tutorial provided by Apple that helped me to understand the basic of core data in iPhone.

But now, working over my project, I've a problem adding data into my database.

When i create an object and set the data, if I try to get it back, the system returns me a strange sequence of characters.

This is what i see in log if I try to log it:

2010-05-11 00:16:43.523 FG[2665:207] Package: ‡}00å
2010-05-11 00:16:43.525 FG[2665:207] Package: ‡}00å
2010-05-11 00:16:43.526 FG[2665:207] Package: ‡}00å
2010-05-11 00:16:43.527 FG[2665:207] Package: ‡}00å
2010-05-11 00:16:43.527 FG[2665:207] Package: ‡}00å
2010-05-11 00:16:43.527 FG[2665:207] Items: 5

What kind of problem could be this?

Edit:

This is the part of the code that generate the error:

package = (Package *)[NSEntityDescription insertNewObjectForEntityForName:@"Package" inManagedObjectContext:moc];

    theNodes = [doc nodesForXPath:@"//pack" error:&error];
    for (CXMLElement *theElement in theNodes)
    {       
        // Create a counter variable as type "int"
        int counter;

        // Loop through the children of the current  node
        for(counter = 0; counter < [theElement childCount]; counter++) {

            if([[[theElement childAtIndex:counter] name] isEqualToString: @"id"])
                [package setIdPackage:[[theElement childAtIndex:counter] stringValue]];
            if([[[theElement childAtIndex:counter] name] isEqualToString: @"title"])
                [package setPackageTitle:[[theElement childAtIndex:counter] stringValue]];
            if([[[theElement childAtIndex:counter] name] isEqualToString: @"category"])
                [package setCategory:[[theElement childAtIndex:counter] stringValue]];
            if([[[theElement childAtIndex:counter] name] isEqualToString: @"lang"])
                [package setLang:[[theElement childAtIndex:counter] stringValue]];
            if([[[theElement childAtIndex:counter] name] isEqualToString: @"number"]) {
                NSNumberFormatter * f = [[NSNumberFormatter alloc] init];
                [f setNumberStyle:NSNumberFormatterDecimalStyle];
                NSNumber * myNumber = [f numberFromString:[[theElement childAtIndex:counter] stringValue]];
                [f release];                
                [package setNumber:myNumber];
            }

        }

    }

    NSLog([NSString stringWithFormat:@"=== %s ===\nID: %s\nCategory: %s\nLanguage: %s",[package packageTitle], [package idPackage] ,[package category],[package lang]]);

© Stack Overflow or respective owner

Related posts about iphone

Related posts about core-data