UA-17470720-3

Jump to content


Photo
- - - - -

type = SCPropertyTypeSelection not giving a table to select from for a custom property


  • Please log in to reply
6 replies to this topic

#1 Dave Guerin

Dave Guerin

    Forum Master

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 545 posts
  • LocationIreland
Reputation: 137
Popular

Posted 07 May 2013 - 08:24 PM

Hi all,
 
If I have:
 

 
SCEntityDefinition *songEntityDefinition = [SCEntityDefinition definitionWithEntityName:@"SongEntity"
                                                                       managedObjectContext:kdgManagedObjectContext
                                                                        propertyNamesString:@":(songName);:(preNotes);:(notes);:(postNotes);:(songHours,songMinutes,songSeconds);:(~mergeWith)"
                                                ];

and then later:
 

  SCPropertyDefinition *mergeWithPropertyDefinition = [songEntityDefinition propertyDefinitionWithName:@"~mergeWith"];
    mergeWithPropertyDefinition.title = @"Merge with…";
    mergeWithPropertyDefinition.type = SCPropertyTypeSelection;
    mergeWithPropertyDefinition.existsInCreationMode = NO;
    mergeWithPropertyDefinition.existsInEditingMode = YES;
    mergeWithPropertyDefinition.existsInNormalMode = NO;
    mergeWithPropertyDefinition.existsInDetailMode = YES;

    mergeWithPropertyDefinition.cellActions.willConfigure = ^(SCTableViewCell *cell, NSIndexPath *indexPath) {
        NSLog(@"mergeSongsPropertyDefinition.cellActions.willConfigure");
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    };
    
    
    NSMutableArray *mergeWithItems = [NSMutableArray arrayWithObjects:@"ITEM 1", @"ITEM 2", @"ITEM 3", nil];
    mergeWithPropertyDefinition.attributes = [SCSelectionAttributes attributesWithItems:mergeWithItems
                                                                 allowMultipleSelection:NO
                                                                       allowNoSelection:YES
                                                                  autoDismissDetailView:YES
                                                            hideDetailViewNavigationBar:NO];

 

When I tap the "Merge with..." cell that should give me a table with 3 cells to select from shouldn't it? Or have I done something wrong?

 

Currently tapping the "Merge with..." cell does nothing other than highlight the cell.

 

If I change SCPropertyTypeSelection to SCPropertyTypeObjectSelection then I do get the table with 3 items to select from, but STV complains a lot, and then I get a crash on selecting an item.

 

 

 


Cheers,

Dave

www.dgapps.ie

#2 Dave Guerin

Dave Guerin

    Forum Master

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 545 posts
  • LocationIreland
Reputation: 137
Popular

Posted 08 May 2013 - 01:22 AM

After further investigation, if I change ~mergeWith to mergeWith where mergeWith is a SongEntity attribute then it all works as expected. A STV bug?

 

Another question, how do I dynamically change the selection items? I tried this:

 

  self.mergeWithPropertyDefinition.cellActions.detailModelWillPresent = ^(SCTableViewCell *cell, NSIndexPath *indexPath, SCTableViewModel *detailModel) {
        weakSelf.mergeWithPropertyDefinition.attributes = [SCSelectionAttributes attributesWithItems:weakSelf.allSongNamesExceptCurrent
                                                                              allowMultipleSelection:NO
                                                                                    allowNoSelection:YES
                                                                               autoDismissDetailView:YES
                                                                         hideDetailViewNavigationBar:NO];
    };

 

but that doesn't work, even though weakSelf.allSongNamesExceptCurrent has the correct values.


Cheers,

Dave

www.dgapps.ie

#3 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 08 May 2013 - 09:30 AM

Hi Dave,

 

a. Keep in mind that whenever you precede a property/attribute name with a tilde (~), you're telling STV that this is a custom property, and an SCCustomPropertyDefinition is generated instead of a regular SCPropertyDefinition. Currently, STV expects you to handle what cell the custom property will generate, essentially ignoring whatever value you have in the property definition's 'type'. Giving this some more thought, I now think STV should still handle the type when you set it. We'll make sure to implement this behavior in our next update.

 

b. At this point, you're using the cell actions of the SCSelectionCell that has been already generated using the SCSelectionAttributes. Therefore, changing the attributes will only affect the next generated cell and not the current one. You should use the SCSelectionCell itself to set the items dynamically:

 

self.mergeWithPropertyDefinition.cellActions.willConfigure = ^(SCTableViewCell *cell, NSIndexPath *indexPath)
{
  SCSelectionCell *selectionCell = (SCSelectionCell *)cell;  // should probably run an isKindOfClass before the cast just in case the cell type changes later on
 
  selectionCell.items = weakSelf.allSongNamesExceptCurrent;
};


#4 Dave Guerin

Dave Guerin

    Forum Master

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 545 posts
  • LocationIreland
Reputation: 137
Popular

Posted 09 May 2013 - 02:54 AM

Hi Tarek,

 

Thanks for the reply.

 

I just tried this but selectionCell.items is readonly.


Cheers,

Dave

www.dgapps.ie

#5 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 10 May 2013 - 02:14 PM

Oh we apologize for that! We'll fix this in 3.2.1 which should be out on Tue.

 

Thank you very much.



#6 Dave Guerin

Dave Guerin

    Forum Master

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 545 posts
  • LocationIreland
Reputation: 137
Popular

Posted 10 May 2013 - 09:12 PM

Hi Tarek,

 

Thanks in advance for fixing this in 3.2.1 :-)

 

I can see that you're really busy, but did you get a chance to look at another of the issues I was experiencing? And there was a second question I slipped into that thread as well:

 

http://sensiblecocoa...type/#entry9017


Cheers,

Dave

www.dgapps.ie

#7 Dave Guerin

Dave Guerin

    Forum Master

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 545 posts
  • LocationIreland
Reputation: 137
Popular

Posted 15 May 2013 - 12:01 AM

Hi Tarek,

I can confirm this is indeed fixed in 3.2.1

Thank you very much!
Cheers,

Dave

www.dgapps.ie




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users