Search code examples
ioscore-datakvc

Strange brackets?


Please anybody now how to remove strange brackets?

strange brackets

Tasting *tasting = [self.fetchedResultsController objectAtIndexPath:indexPath];
cell.creationDate.text = [[tasting valueForKey:@"creationDate"] description];
cell.wineName.text = [[[tasting wine]valueForKey:@"wineName"]description];

Solution

  • OK, so the object stored as wineName is an NSSet, which explains why you are getting the value in the form {( "name" )} when calling the description method. Exactly why it's an NSSet object is unknown to me, given a wine a generally marketed under just one name...

    To get it in your preferred format don't use description, and instead pull the value out and display like this:

    NSSet *wines = [[tasting wine] valueForKey:@"wineName"];
    cell.wineName.text = [wines anyObject];
    

    You will also want to do something similar with the date column, using an NSDateFormatter object to format it to the user's preferred format.