Welcome, Guest
Username Password: Remember me

Form Numbering
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: Form Numbering

Form Numbering 1 year, 5 months ago #1

Morning

Is it possible to auto number a form ?

For example, I set up a standard form - like a tasks, that will provide the form a number that will auto increment in order to keep the form unique.

Regards

Iain
  • ihmunro
  • OFFLINE
  • Expert Boarder
  • Posts: 135
  • Karma: 0

Re: Form Numbering 1 year, 5 months ago #2

I am assuming here that you have an SCLabelCell or an SCTextFieldCell where you'll have this "Form ID" in. In Sensible TableView, you always have access to the newly created object via an SCTableViewModelDelegate method called tableViewModel:itemCreatedForSectionAtIndex:item:. Here is a code sample illustrating how to achieve what you want (please check SCTableViewModelDelegate documentation for a full explanation of the method):

 
// Make sure you're conforming to the SCTableViewModelDelegate protocol in the header file before implementing this method
- (void)tableViewModel:(SCTableViewModel *)tableViewModel
itemCreatedForSectionAtIndex:(NSUInteger)index item:(NSObject *)item
{
MyForm *form = (MyForm *)item;
 
// Assuming MyForm has a property called id
form.id = [self getUniqueFormNumber];
}
 


The above code is assuming MyForm is a custom object representing your form and getUniqueFormNumber is a custom method that returns a unique number. If you're using Core Data instead, then the code should look something like this:

 
- (void)tableViewModel:(SCTableViewModel *)tableViewModel
itemCreatedForSectionAtIndex:(NSUInteger)index item:(NSObject *)item
{
NSManageObject *managedObject = (NSManagedObject *)item;
 
// Assuming the form entity has an attribute called "id"
[managedObject setValue:[self getUniqueFormNumber] forKey:@"id"];
}
 


Please tell me if you need any more help.
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2402
  • Karma: 72

Re: Form Numbering 1 year, 5 months ago #3

Many thanks
  • ihmunro
  • OFFLINE
  • Expert Boarder
  • Posts: 135
  • Karma: 0
  • Page:
  • 1
Time to create page: 0.77 seconds