UA-17470720-3

Jump to content


Photo
- - - - -

Use SCPropertyTypeTextField in lieu of SCPropertyTypeObjectSelection in Relationship

data-definitions cells actions

  • Please log in to reply
3 replies to this topic

#1 TODD GARLAND

TODD GARLAND

    Experienced Member

  • STV 4.0 Pro
  • PipPipPipPip
  • 69 posts
Reputation: 21
Excellent

Posted 22 January 2014 - 07:05 AM

I have one to one relationship set up between the two below entities.

 

SCEntityDefinition *testDef = [SCEntityDefinition definitionWithEntityName:@“testEntity" managedObjectContext:localContext propertyNamesString:@"Identifiers:(testNo,GPS:(coordinates)"];

    //end new code

 

 

SCEntityDefinition *gpsEntity = [SCEntityDefinition definitionWithEntityName:@"GPSEntity"

managedObjectContext:localContext

propertyNamesString:@"GPS Details:(latitude)"];

 

what I want to do is have a SCPropertyTypeTextField type in lieu of SCPropertyTypeObjectSelection type with the value of latitude for the GPS coordinates in the testDef.

 

So instead of this:

SCPropertyDefinition *coordinatePropertyDef = [testDef propertyDefinitionWithName:@"coordinates"];

    coordinatePropertyDef.type = SCPropertyTypeObjectSelection;

    coordinatePropertyDef.title = NSLocalizedString(@"Coordinates",nil);

 

I want:

 

SCPropertyDefinition *coordinatePropertyDef = [testDef propertyDefinitionWithName:@"coordinates"];

    coordinatePropertyDef.type = SCPropertyTypeTextField;

    coordinatePropertyDef.title = NSLocalizedString(@"Coordinates",nil);

 

But when I use the above, the cell is not created.

 

However, when I used SCPropertyTypeArrayOfObjects the cell is created but with a “0” in the cell. Then it appears I have to create the array etc. Something similar to the SCPropertyTypeObjectSelection.

 

 

Have looked at key binding, object binding etc, but do not want to create custom cell just for this.

 

Per chance is this possible?



#2 TODD GARLAND

TODD GARLAND

    Experienced Member

  • STV 4.0 Pro
  • PipPipPipPip
  • 69 posts
Reputation: 21
Excellent

Posted 22 January 2014 - 12:17 PM

Resolved issue by implementing a version of this code to match my requirements:

 

SCEntityDefinition *entityDef = [SCEntityDefinition definitionWithEntityName:@"MyEntity" managedObjectContext:context propertyNamesString:@"myAttr1;myAttr2;~customLabel"];
SCPropertyDefinition *customLabelPDef = [entityDef propertyDefinitionWithName:@"~customLabel"];
customLabelPDef.type = SCPropertyTypeLabel;
customLablePDef.cellActions.willDisplay = ^(SCTableViewCell *cell, NSIndexPath *indexPath)
{
NSDate *dateValue = [cell.boundObject valueForKey:@"myDateAttribute"];
NSNumber *amountValue = [cell.boundObject valueForKey:@"myAmountAttribute"];

SCLabelCell *labelCell = (SCLabelCell *)cell;
labelCell.label.text = [NSString stringWithFormat:@"%@ - $%@", dateValue, amountValue];
};



#3 ozie

ozie

    ¯\_(ツ)_/¯

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 526 posts
  • LocationAustralia
Reputation: 169
Popular

Posted 22 January 2014 - 02:53 PM

might have been because of an invalid string you have on the first line

@"Identifiers:(testNo,GPS:(coordinates)"

its missing a )


P.S. I hate Swift.. don't talk Swift.. Too old school to learn yet another programming language.


#4 TODD GARLAND

TODD GARLAND

    Experienced Member

  • STV 4.0 Pro
  • PipPipPipPip
  • 69 posts
Reputation: 21
Excellent

Posted 22 January 2014 - 03:29 PM

Oz,

 

Thanks for the reply, that was typo in my posting- when I cut and pasted







Also tagged with one or more of these keywords: data-definitions, cells, actions

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users