UA-17470720-3

Jump to content


Photo
- - - - -

Core Data Double creation of meta data for attribute

data-stores core-data

  • Please log in to reply
5 replies to this topic

#1 TODD GARLAND

TODD GARLAND

    Experienced Member

  • STV 4.0 Pro
  • PipPipPipPip
  • 69 posts
Reputation: 21
Excellent

Posted 08 January 2015 - 01:23 PM

Gents,

 

Don't know if I can explain this properly. I have core data model with one to many relationships (person/address).

 

Created mastercontroller in IB with scarray of objects. I import existing names with addresses from remote site. I then launch, select my person, and  push the address view controller and enter in data for that person. I use the following STV method on the mastercontroller to update core data. Within the method below, I update address using name predicate, fetch, blah, blah, blah and everything is jake.

 

objectsSection.sectionActions.didUpdateItem = ^(SCArrayOfItemsSection *itemsSection, NSObject *item, NSIndexPath *indexPath){

 }

 

I subsequently hit the standard STV "Done" button and think I'm cool until I use mesaSQLLite to look at table contents. Within the address table, I find that the address for the name selected is updated as expected, but lo and behold, a duplicate address entry has been added.

 

Any thoughts/ideas would be appreciated,

 

Thanks

 

TRG



#2 David DelMonte

David DelMonte

    Forum Master

  • STV 4.0 Pro
  • PipPipPipPipPipPipPip
  • 527 posts
Reputation: 41
Excellent

Posted 08 January 2015 - 01:28 PM

@Todd, is this reproducible (nice way of asking if you may have pressed the Done button twice). Is that done routine performed in more than one place?



#3 TODD GARLAND

TODD GARLAND

    Experienced Member

  • STV 4.0 Pro
  • PipPipPipPip
  • 69 posts
Reputation: 21
Excellent

Posted 08 January 2015 - 01:40 PM

Dave,

 

Thanks for the quick reply, been working this problem for 6 or so hours.

 

I only push the done button once and only using the method objects section didupdateitem. What I am thinking is the save is getting triggered twice, once on the mastercontroller when done button is pressed, but also on the detail view controller that is being closed when I finish inputting the addresses changes. However for the life of me, I have no idea how to trigger cell selection on the detail controller when it is built using the IB. Tried all the solutions/actions or snippets on the forum without luck. I have to believe I am just plain ignorant or missing something.

 

Thanks

TRG


  • David DelMonte likes this

#4 David DelMonte

David DelMonte

    Forum Master

  • STV 4.0 Pro
  • PipPipPipPipPipPipPip
  • 527 posts
Reputation: 41
Excellent

Posted 08 January 2015 - 02:30 PM

I'm thinking that in my project, I will need to specify a discreet DetailViewController class. I can do a ton in IB w/ v4, but there are some things (adding an image view for example), that I don't think I can do with a controller class in code.

 

Hopefully, Tarek or Ozie will correct us.

 

One thing I've done up to now, has been to specify detail sub items (i.e. items that need selection) as SCObjectSelections. In the Core Data app sample, we often refer to the Task Steps Entity, which are set up using an ArrayOfObjects. There is a nugget in that sample that deals with task assignments. The PersonEntity, and it's code. I've used that with some success. 

 

Last, are you saving stuff through the app delegate? If so, you can log it's activity..

 

Hope this helps.



#5 ozie

ozie

    ¯\_(ツ)_/¯

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 526 posts
  • LocationAustralia
Reputation: 169
Popular

Posted 08 January 2015 - 08:50 PM

Todd..

 

instead of using didUpdateItem.. have u tried willUpdateItem and do the changes there?? in this call, before the data is applied to the store you can make changes

 

didUpdateItem should fire after the item has been updated in the database.. and if in there you are coding something that also makes additions/changes to data, this might be causing the dups


P.S. I hate Swift.. don't talk Swift.. Too old school to learn yet another programming language.


#6 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 19 January 2015 - 08:51 AM

Hi Todd,

 

Can you point me to any of our samples where this issue exists? (or what modifications to do to them to replicate this)







Also tagged with one or more of these keywords: data-stores, core-data

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users