UA-17470720-3

Jump to content


Photo
- - - - -

Section index table view for SCArrayOfObjectsAttributes?


  • Please log in to reply
14 replies to this topic

#1 Udo von Eynern

Udo von Eynern

    Starting Out

  • STV 3.0 Pro
  • Pip
  • 9 posts
Reputation: 0
Neutral

Posted 10 August 2012 - 09:16 AM

Hey,

first I want to thank SensibleCocoa for this great framework, I'm using it in three different customer projects and beside some small issues it just works great and saves my time and the customer's money ;-)

My question now... I want to have a section index table view instead of a standard table view for the selection of objects. Here is my code, how can I integrate an ABC index on the right for this selection of objects?

			SCPropertyDefinition *competitorModelTypePropertyDef = [opportunityCompetitorMachineClassDef propertyDefinitionWithName:@"modelType"];
			competitorModelTypePropertyDef.type = SCPropertyTypeObjectSelection;
			competitorModelTypePropertyDef.title = NSLocalizedString(@"Foreign Machine", nil);
			competitorModelTypePropertyDef.required = YES;
			competitorModelTypePropertyDef.existsInEditingMode = NO;
			competitorModelTypePropertyDef.existsInDetailMode = NO; 
			
			
			competitorModelTypePropertyDef.cellActions.willSelect = ^(SCTableViewCell *cell, NSIndexPath *indexPath) {

				SCObjectSelectionCell *myCell = (SCObjectSelectionCell *)cell;
				
				SCArrayOfObjectsAttributes *machineSelectionAttributes = [SCObjectSelectionAttributes attributesWithSelectionObjects:self.modelTypes objectsDefinition:modelTypeClassDef allowMultipleSelection:NO allowNoSelection:NO];
				machineSelectionAttributes.allowAddingItems = NO;
				machineSelectionAttributes.allowDeletingItems = NO;
				machineSelectionAttributes.allowMovingItems = NO;
				machineSelectionAttributes.allowEditingItems = NO;
				machineSelectionAttributes.placeholderuiElement = [SCTableViewCell cellWithText:@"(n/a"];
				competitorMachineGroupPropertyDef.attributes = machineSelectionAttributes; 
				
				
				[myCell setAttributesTo:machineSelectionAttributes];  
			}; 

Using version 3.0.5 of sensible table view, without core data support.

Is there anybody out there who could help me or give me a hint?

Best,
Udo

#2 poffel

poffel

    Advanced Member

  • STV 5.0 Pro
  • PipPipPipPipPip
  • 116 posts
Reputation: 19
Good

Posted 10 August 2012 - 09:46 AM

SCArrayOfObjectsModel *model = [[SCArrayOfObjectsModel alloc] initWithTableView:self.tableView entityDefinition:MyEntityDef];
  
model.autoSortSections = TRUE;  
	
model.sectionIndexTitles = [NSArray arrayWithObjects:@"A", @"B", @"C", @"D", @"E", @"F", @"G", @"H", @"I", @"J", @"K", @"L", @"M", @"N", @"O", @"P", @"Q", @"R", @"S", @"T", @"U", @"V", @"W", @"X", @"Y", @"Z", nil];

- (NSString *)tableViewModel:(SCArrayOfItemsModel *)tableViewModel sectionHeaderTitleForItem:(NSObject *)item AtIndex:(NSUInteger)index {

	NSString *sectionName = nil;
 
		NSManagedObject *managedObject = (NSManagedObject *)item;
		
		NSString *objectName = (NSString *)[managedObject valueForKey:@"name"];
		
		sectionName = [[objectName substringToIndex:1] uppercaseString];

	return sectionName;
}

just wrote out of my mind. Untested though but should give you a direction to start with :-)

#3 Udo von Eynern

Udo von Eynern

    Starting Out

  • STV 3.0 Pro
  • Pip
  • 9 posts
Reputation: 0
Neutral

Posted 10 August 2012 - 03:51 PM

Hey poffel, thanks for your help, but I do not use Core Data in the app and I want to customize the detail view of SCPropertyTypeObjectSelection.

Here ist my first try, but unfortunately SCObjectSelectionAttributes does not support sectionActions.detailViewControllerForRowAtIndexPath . Here is my current code:

			competitorModelTypePropertyDef.cellActions.willSelect = ^(SCTableViewCell *cell, NSIndexPath *indexPath) {

				SCObjectSelectionCell *myCell = (SCObjectSelectionCell *)cell;

				SCObjectSelectionAttributes *machineSelectionAttributes = [SCObjectSelectionAttributes attributesWithSelectionObjects:self.modelTypes objectsDefinition:modelTypeClassDef allowMultipleSelection:NO allowNoSelection:NO];
				machineSelectionAttributes.allowAddingItems = NO;
				machineSelectionAttributes.allowDeletingItems = NO;
				machineSelectionAttributes.allowMovingItems = NO;
				machineSelectionAttributes.allowEditingItems = NO;
				machineSelectionAttributes.placeholderuiElement = [SCTableViewCell cellWithText:@"(n/a"];

				machineSelectionAttributes.sectionActions.detailViewControllerForRowAtIndexPath = ^UIViewController*(SCTableViewSection *section, NSIndexPath *indexPath)
				{
					ABCViewController *detailView = [[ABCViewController alloc] initWithNibName:@"ABCViewController" bundle:nil];
					detailView.modelTypes = self.modelTypes;
					
					return detailView;
				};				 
				competitorMachineGroupPropertyDef.attributes = machineSelectionAttributes;

				[myCell setAttributesTo:machineSelectionAttributes];  
			}; 

For ANY help I would be very grateful!! :-)

#4 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 11 August 2012 - 07:08 PM

Hi Udo,

Thanks a lot for all your complements, we're really proud that STV could help you that much :)

Regarding your question: so what you want is for the automatically created selection detail view to have "ABCD..." section titles on the right. Did I correctly understand that? Also, do u need any searching functionality or is it just the section titles?

#5 Udo von Eynern

Udo von Eynern

    Starting Out

  • STV 3.0 Pro
  • Pip
  • 9 posts
Reputation: 0
Neutral

Posted 12 August 2012 - 08:45 AM

Only the ABCD on the right side of the table view would save my day. Do you have any hints for me, Tarek? Is it possible? Thanks in advance!!

#6 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 13 August 2012 - 05:56 PM

Hi Udo,

I would also guess that, in addition to the ABCD section titles, you probably need STV to automatically group your selection items into sections, giving each section an alphabet letter title (much like Apple's Contacts App). If your selection was a regular SCSelectionCell, then this would've been really simple by using an SCSelectionModel. Since you're selecting from objects however, you'd need a new SCObjectSelectionModel class developed. We can have this new class ready for our next STV release. Do you have a certain deadline for this?

#7 Udo von Eynern

Udo von Eynern

    Starting Out

  • STV 3.0 Pro
  • Pip
  • 9 posts
Reputation: 0
Neutral

Posted 13 August 2012 - 06:10 PM

Hi Tarek,

thanks for your response. Would be great if you could add this feature in the next release. My deadline for this feature is Friday.:unsure: If I could help you in anyhow, please just let me know!

#8 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 14 August 2012 - 03:54 PM

Hey Udo,

Fri is way too early to develop, test and release such a class. We can try to give you something that's untested but that won't be good for production at all.

#9 Udo von Eynern

Udo von Eynern

    Starting Out

  • STV 3.0 Pro
  • Pip
  • 9 posts
Reputation: 0
Neutral

Posted 14 August 2012 - 09:34 PM

An untested version would be fine! I could test it by myself and could give you feedback. Thanks in advance, Tatek!

#10 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 17 August 2012 - 08:35 AM

Hi Udo,

Ok the SCObjectSelectionModel is good, but it turns out that we also need to modify the core STV files to recognize the new model (specifically the buildModel methods). This means that we must wait until version 3.1 is released. Can you postpone this functionality for about a week?

#11 codebonbon

codebonbon

    Advanced Member

  • STV 3.0 Pro
  • PipPipPipPipPip
  • 181 posts
Reputation: 8
Good

Posted 17 August 2012 - 12:22 PM

Hi Tarek!

If i'm reading well then there is the possibility of a release next week? Have any ideas on what this next release corrects/updates?

Cheers!

#12 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 17 August 2012 - 07:29 PM

Hi Harold,

It's just a small update with some bug fixes :)

#13 Udo von Eynern

Udo von Eynern

    Starting Out

  • STV 3.0 Pro
  • Pip
  • 9 posts
Reputation: 0
Neutral

Posted 21 August 2012 - 01:35 PM

Hi Tarek,

sorry for my late response, had to wait for the customers feedback. And yes, they want to wait for the next release. Can you determine a date for the release?

Thanks in advance, again!

Udo

#14 Udo von Eynern

Udo von Eynern

    Starting Out

  • STV 3.0 Pro
  • Pip
  • 9 posts
Reputation: 0
Neutral

Posted 02 September 2012 - 10:45 AM

Hi Tarek,

any updates regarding the next release including the ABC feature? My customer really needs this feature, because they have a list of 1000 entries and the planned release date of the app is coming closer.

Regards
Udo

#15 codebonbon

codebonbon

    Advanced Member

  • STV 3.0 Pro
  • PipPipPipPipPip
  • 181 posts
Reputation: 8
Good

Posted 12 September 2012 - 06:35 PM

Hi Tarek!

Looking forward for this upadte also. I'm thinking your brewing something amazing as always which i why we haven't seen lotsa replies on the forum. ;-)

Anxiously!

Harold




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users