Add NSArray category to mimic retrieve and delete in NSManagedObject category #514

Closed
wants to merge 2 commits into
from

Projects

None yet

3 participants

rayray commented Jul 10, 2013

In response to issue #513

Owner

So, I'm trying to move away from the inThreadContext type methods. Those have caused many people so much grief, and many more support issues for me and the team.

rayray commented Jul 10, 2013

That works out because I don't use them. :)

Just wanted to make sure I was replicating the functionality in NSManagedObject+MagicalRecord. MR_inContext and the deletes seem very useful, though.

Owner

Though, while you're traversing an NSArray, it may be prudent to add checks that objects are actually NSManagedObjects while traversing the array. I mean, you can call this method from ANY NSArray with ANY objects in it...as a "framework" MagicalRecord does have to warn people about this sorta stuff :(

On Jul 10, 2013, at 7:51 AM, rmndk notifications@github.com wrote:

That works out because I don't use them. :)

Just wanted to make sure I was replicating the functionality in NSManagedObject+MagicalRecord. MR_inContext and the deletes seem very useful, though.


Reply to this email directly or view it on GitHub.

rayray commented Jul 10, 2013

I understand. I had thought unrecognized selector would suffice for the sake of efficiency, but I see what you mean about frameworks. I'd lose that pretty makeObjectsPerformSelector:. :(

How would you prefer the methods to fail? Perhaps return nil for the arrays? Give up on deletes halfway through an array?

Owner

I pretty much go with NSAssert these days myself. It's simple enough and gets the message across pretty quick.

On Jul 10, 2013, at 8:21 AM, rmndk notifications@github.com wrote:

I understand. I had thought unrecognized selector would suffice for the sake of efficiency, but I see what you mean about frameworks. I'd lose that pretty makeObjectsPerformSelector:. :(

How would you prefer the methods to fail? Perhaps return nil for the arrays? Give up on deletes halfway through an array?


Reply to this email directly or view it on GitHub.

rayray commented Jul 11, 2013

Added asserts and squashed the previous commits.

Owner

A couple things still :(

First, the cast is not necessary on id vars. I know you're trying to be specific, but. It's just extra cruft, even to the compiler.

There should also be inContext variants of each method, even on arrays. My personal rule is always pass in the context, and then have a method that chooses the right context for that method.

rayray commented Jul 11, 2013

I appreciate your persistence. :)

So:

  1. I think I have to leave the cast in MR_deleteInContext:, because the compiler will be confused when I attempt to call the same method on NSManagedObject. Xcode doesn't like it.
  2. I'm not sure what you mean by inContext variants, I thought I got them all. MR_deleteInContext is the variant of MR_deleteEntities.
Owner

Almost there. In mr_deleteEntities, it just uses the method of the same name on each object. I think it's better to bra but more explicit about the context being used there,and use the deleteincontext method there.

Owner

Also, I don't think I noticed a change in the main header file that
includes everything. That's be a good thing to add do k can do an auto
merge.

Thanks for being patient with me on this

Saul Mora
@casademora

On Jul 10, 2013, at 8:16 PM, rmndk notifications@github.com wrote:

I appreciate your persistence. :)

So:

  1. I think I have to leave the cast in MR_deleteInContext:, because the
    compiler will be confused when I attempt to call the same method on
    NSManagedObject. Xcode doesn't like it.
  2. I'm not sure what you mean by inContext variants, I thought I got
    them all. MR_deleteInContext is the variant of MR_deleteEntities.


Reply to this email directly or view it on
GitHubhttps://github.com/magicalpanda/MagicalRecord/pull/514#issuecomment-20786204
.

rayray commented Jul 11, 2013

Quick explanation:

  • Casts remain at appropriate points to prevent confusion on which same-named method to call
  • Added the #import after NSManagedObject categories because it seemed appropriate
rayray commented Jul 11, 2013

Anything more I need to do? Did I miss anything else? 😄

Owner

I'm on the road at the moment, But it looks ok for now. Thanks for the
contribution!

Saul Mora
@casademora

On Jul 11, 2013, at 1:32 PM, rmndk notifications@github.com wrote:

Anything more I need to do?


Reply to this email directly or view it on
GitHubhttps://github.com/magicalpanda/MagicalRecord/pull/514#issuecomment-20835877
.

rayray commented Aug 26, 2013

Anything I can do to move this along? I'd still love to have this without using my fork. :)

Owner

Thanks for the bump, I'll see what I can do to get this in soon

rayray commented Mar 3, 2014

Bumping again. Is this forgotten or dead? :)

Contributor

I've added this to MagicalRecord 3.0 in 499300e. Thanks!

@tonyarnold tonyarnold closed this Apr 8, 2014
@tonyarnold tonyarnold self-assigned this Apr 8, 2014
@tonyarnold tonyarnold added this to the 3.0.0 milestone Apr 8, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment