UA-17470720-3

Jump to content


Photo
- - - - -

SCArrayOfObjectsModel adding new item through error

models actions view-controllers

  • Please log in to reply
6 replies to this topic

#1 Balachandhar

Balachandhar

    Experienced Member

  • STV 3.0 Pro
  • PipPipPipPip
  • 87 posts
Reputation: 21
Excellent

Posted 22 January 2013 - 09:42 AM

I am using SCArrayOfObjectsModel to load a list of items in a tableview, the modelview has a 'add' button. But my app get crash after pressing the "Done" button in add view.

This is the xcode crash log:


*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 2147483647 beyond bounds [0 .. 0]'
*** First throw call stack:

This is the code snippet which i am using now.


UIBarButtonItem *addButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:nil action:nil];
self.navigationItem.leftBarButtonItem = nil;
self.navigationItem.rightBarButtonItem = addButtonItem;

SCParseComDefinition *taskDef = [SCParseComDefinition definitionWithClassName:@"Contact" columnNamesString:@"firstName;prefix;lastName;notes;title;companyCheck;" applicationId:applicationId restAPIKey:restAPIKey];
[taskDef propertyDefinitionWithName:@"prefix"].required=TRUE;
[taskDef propertyDefinitionWithName:@"firstName"].required=TRUE;
[taskDef propertyDefinitionWithName:@"lastName"].required=TRUE;
SCPropertyDefinition *descPDef = [taskDef propertyDefinitionWithName:@"notes"];
descPDef.type = SCPropertyTypeTextView;
SCPropertyDefinition *companyCheckPDef = [taskDef propertyDefinitionWithName:@"companyCheck"];
companyCheckPDef.type = SCPropertyTypeSwitch;
SCWebServiceStore *webStore = [SCWebServiceStore storeWithDefaultWebServiceDefinition:taskDef];
SCArrayOfObjectsModel *webModel = [[SCArrayOfObjectsModel alloc] initWithTableView:self.tableView dataStore:webStore];
webModel.dataFetchOptions = [SCWebServiceFetchOptions options];
webModel.addButtonItem = self.navigationItem.rightBarButtonItem;
webModel.searchBar = searchBar;
//search by both first and last names
webModel.searchPropertyName = @"firstName;lastName";
webModel.autoSortSections = YES;
// webModel.autoGenerateSectionIndexTitles = TRUE;
webModel.sectionIndexTitles = [NSArray arrayWithObjects:
@"{search}", @"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];
webModel.modelActions.sectionHeaderTitleForItem =
^NSString*(SCArrayOfItemsModel *itemsModel, NSObject *item,
NSUInteger itemIndex)
{
NSString *objectName = (NSString *)[item
valueForKey:@"firstName"];
// Return first character of objectName
return [[objectName substringToIndex:1] uppercaseString];
};
webModel.dataFetchOptions.sort = TRUE; // Sort names
webModel.detailViewControllerOptions.navigationBarType = SCNavigationBarTypeDoneRightCancelLeft;

self.tableViewModel = webModel;

-Thanks,
bala

#2 Balachandhar

Balachandhar

    Experienced Member

  • STV 3.0 Pro
  • PipPipPipPip
  • 87 posts
Reputation: 21
Excellent

Posted 23 January 2013 - 01:05 AM

Anyone know the reason? pls...

#3 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 23 January 2013 - 01:54 PM

Hi bala,

The error message is really strange. Are you able to attach a sample that demonstrates this? Thank you.

#4 Balachandhar

Balachandhar

    Experienced Member

  • STV 3.0 Pro
  • PipPipPipPip
  • 87 posts
Reputation: 21
Excellent

Posted 24 January 2013 - 09:47 AM

Hi Tarek,

The project size is comes arround 18 MB due to the Sensible touch and parse.com framework. Could you send me your email id? so that I can send you the code.

Thanks,
bala.

#5 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 24 January 2013 - 10:20 AM

Hi bala,

Just kindly create a new support ticket and upload your project there (no need to include the STV framework in the project files).

#6 Balachandhar

Balachandhar

    Experienced Member

  • STV 3.0 Pro
  • PipPipPipPip
  • 87 posts
Reputation: 21
Excellent

Posted 24 January 2013 - 10:41 AM

Hi Tarek,

Please find the project file, kindly add the following framework in the project folder(screenshot attached). Also, I dont know how to fetch a list of another parse.com objects and make them as one of the selection cell of maintable view. Please help me to do the same.

Thanks,
bala.

Attached Files



#7 Balachandhar

Balachandhar

    Experienced Member

  • STV 3.0 Pro
  • PipPipPipPip
  • 87 posts
Reputation: 21
Excellent

Posted 24 January 2013 - 10:53 AM

I have a tableview with multiple rows. each row represent an object of a parse.com class, the detail view of selected row has a object ID of another parse.com class. So, instead of showing that ID in my detail view I want to show a selection cell, that selection cell will show that particular object's details. Help me to achieve this, I know how do it without using the Sensible Touch but i don't know using SCT. I am trying this from last two days actually.

Thanks,
bala.





Also tagged with one or more of these keywords: models, actions, view-controllers

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users