Welcome, Guest
Username Password: Remember me

storing pre-set data
(1 viewing) (1) Guest
  • Page:
  • 1
  • 2

TOPIC: storing pre-set data

storing pre-set data 1 year, 8 months ago #1

Hi,

I have a core data model that has latitude/longitude in it. When storing a record, I want my app to use a CoreLocation call to get the latitude/longitude and store it in Core Data for that record. But I don't see how to set it up to do that. Is there an example that can show me how?

thx,
wes
  • Wes42
  • OFFLINE
  • Fresh Boarder
  • Posts: 13
  • Karma: 0

Re: storing pre-set data 1 year, 8 months ago #2

In our upcoming release we have added a delegate method called tableViewModel:itemCreatedForSectionAtIndex:item: . You can use the following code to achieve what you want as soon as the managed object is created (I'll send you a pre-release RC version on your email):

 
- (void)tableViewModel:(SCTableViewModel *)tableViewModel
itemCreatedForSectionAtIndex:(NSUInteger)index item:(NSObject *)item
{
// This step is not actually neccessary but I included it just for clarity
NSManagedObject *managedObject = (NSManagedObject *)item;
 
// Now assuming you have attributes called "latitude" and "longitude"
[managedObject setValue:currentLatitude forKey:@"latitude"];
[managedObject setValue:currentLongitude forKey:@"longitude"];
}
 


That should do the trick!
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2404
  • Karma: 72

Re: storing pre-set data 1 year, 8 months ago #3

Thx, I will try it out tonight.

One other question. When working with CoreData, is there the ability to use a `withPlaceholder` as I have seen in your `Key Binding` example. I want to put into the cell a little hint of what to type in.

wes
  • Wes42
  • OFFLINE
  • Fresh Boarder
  • Posts: 13
  • Karma: 0

Re: storing pre-set data 1 year, 8 months ago #4

Sure you can do that Wes. All you need to do is set the attributes property of your property definition to an SCTextFieldAttributes instance. Here is an example:

 
...
SCPropertyDefinition *propertyDef = [myClassDef propertyDefinitionWithName:@"myTextAttribute"];
propertyDef.attributes = [SCTextFieldAttributes attributesWithPlaceholder:@"enter text here"];
...
 
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2404
  • Karma: 72

Re: storing pre-set data 1 year, 8 months ago #5

Thx but that last code sample (with PlaceHolder) did not show anything. Maybe I have an old(er) version of SCTableview; I have 1.5.5.
Also, I too have the same problem with the SCPropertyTypeTestView dismissing the keyboard. I am on iOS 4.1.

thx,
wes
  • Wes42
  • OFFLINE
  • Fresh Boarder
  • Posts: 13
  • Karma: 0

Re: storing pre-set data 1 year, 8 months ago #6

The placeholder code should work with your version, would you please post your class definition code?

I'll send you now our latest pre-release RC version that should solve your SCTextViewCell issue.
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2404
  • Karma: 72
  • Page:
  • 1
  • 2
Time to create page: 2.62 seconds