Re: Core Data debugging

2009-07-16 Thread Fritz Anderson
On 15 Jul 2009, at 6:14 PM, tmow...@talktalk.net wrote: (gdb) po err Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_PROTECTION_FAILURE at address: 0x 0x922e668c in objc_msgSend () (Earlier:) NSError *err; BOOL result = [moc save: err]; Are you sure

Re: Core Data debugging (Fritz Anderson)

2009-07-16 Thread tmowlem
On 17 Jul 2009, at 00:13 AM, Fritz Anderson fri...@manoverboard.org wrote: On 15 Jul 2009, at 6:14 PM, tmow...@talktalk.net wrote: (gdb) po err Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_PROTECTION_FAILURE at address: 0x 0x922e668c

Re: Core Data debugging

2009-07-16 Thread BJ Homer
NSError *err; BOOL result = [moc save: err]; Make sure you initialize err: NSError *err = nil; Otherwise, you may be dealing with a bogus error object, since method-scope variables are not automatically initialized to 0. (Instance variables are initialized, btw.) I don't think that

Re: Core Data debugging

2009-07-16 Thread Bill Bumgarner
NSError *err; BOOL result = [moc save: err]; Make sure you initialize err: NSError *err = nil; Otherwise, you may be dealing with a bogus error object, since method-scope variables are not automatically initialized to 0. (Instance variables are initialized, btw.) I don't think

Re: Core Data debugging

2009-07-16 Thread Kyle Sluder
On Thu, Jul 16, 2009 at 1:26 PM, Bill Bumgarnerb...@mac.com wrote: You should *never* assume *anything* about the value of err across a call to -save: or any other similar method *unless* the result indicates an error. This makes many people's lives difficult. It's kinda bogus that if I pass

Re: Core Data debugging

2009-07-16 Thread Bill Bumgarner
On Jul 16, 2009, at 1:37 PM, Kyle Sluder wrote: This makes many people's lives difficult. It's kinda bogus that if I pass in the address of a pointer-to-NULL and receive back a YES that I have to turn around and re-NULL that pointer before reusing it. Many AppKit methods have a tendency to

Re: Core Data debugging (Fritz Anderson)

2009-07-16 Thread mmalc Crawford
On Jul 16, 2009, at 12:51 PM, tmow...@talktalk.net wrote: I have removed it completely and just called the longer winded [[NSApp delegate] managedObjectContext] when I need it. I suppose I could have set the ivar in the awakeFromNib when all NIB objects are guaranteed to have been

Re: Core Data debugging

2009-07-16 Thread Timothy Wood
On Jul 16, 2009, at 1:58 PM, Bill Bumgarner wrote: Then your macros are buggy. According to the rules now, quite possibly. But the rules are kinda busted. One place that looking at *outError and being able to assume it would be nil on the *entry* to a NSError-returning method is

Re: Core Data debugging

2009-07-16 Thread Quincey Morris
On Jul 16, 2009, at 15:19, Timothy Wood wrote: then at xxx you'd like to build a new NSError that has *outError (if outError != NULL) as the underlying error. This is perfectly OK since we are on the failure side. Unless the developer of -bar: forgot to actually set *outError (clang

Re: Core Data debugging

2009-07-16 Thread Kyle Sluder
On Thu, Jul 16, 2009 at 3:54 PM, Quincey Morrisquinceymor...@earthlink.net wrote: If I've misunderstood your point, it would be helpful to see an example of how your code might look with the NSError-wrapping code in place. The point is that convenience is increased if NSError-returning methods

Re: Core Data debugging

2009-07-16 Thread Quincey Morris
On Jul 16, 2009, at 15:54, Quincey Morris wrote: On Jul 16, 2009, at 15:19, Timothy Wood wrote: then at xxx you'd like to build a new NSError that has *outError (if outError != NULL) as the underlying error It seems to be you have this precisely upside-down. outError is an output

Re: Core Data debugging

2009-07-16 Thread Timothy Wood
On Jul 16, 2009, at 3:54 PM, Quincey Morris wrote: Aside: If the developer of bar forgot to set *outError, then the developer of bar forgot to set an output parameter, and that's not just a bug on the developer's part, but a *horrible* bug. Sure. And clang-sa should check for this and

Re: Core Data debugging

2009-07-16 Thread Greg Parker
On Jul 16, 2009, at 4:49 PM, Timothy Wood wrote: Sure, I should remember to ignore it or initialize it to nil myself or have a OBBaseError macro, but one day I'll forget. The current rules make me write more and more fragile code than I'd need to if we could just all depend on setting

Re: Core Data debugging

2009-07-16 Thread Quincey Morris
On Jul 16, 2009, at 16:49, Timothy Wood wrote: So, as an example, I might want do do something like: - (BOOL)saveSomething:(NSError **)outError; { NSData *data = build some data; if ([data writeToFile:path options:someOptions error:outError]) return YES;

Re: Core Data debugging

2009-07-16 Thread Timothy Wood
On Jul 16, 2009, at 5:39 PM, Greg Parker wrote: The alternative would be to require the caller to set `err=nil` before calling `whateverWithError:err`. Yes, and this would a code savings. Only at the top level invocations would you need to worry about this. There are far more methods

Re: Core Data debugging

2009-07-16 Thread Timothy Wood
On Jul 16, 2009, at 5:44 PM, Quincey Morris wrote: In the second case, you're not screwed because of these NSError rules but because you're using an output parameter of the method as an input parameter to the macro. It's a plain bug, unless you assert it not to be a bug (which is basically

Re: Core Data debugging

2009-07-16 Thread Quincey Morris
On Jul 16, 2009, at 18:33, Timothy Wood wrote: and if there's something to do that doesn't return a NSError: if (![... do something ...]) { OBError (nil, ...); return NO; } Um, no. This doesn't fill *outError if you pass nil. Either way,

Re: Core Data debugging

2009-07-16 Thread Ben Trumbull
On Jul 16, 2009, at 4:49 PM, Timothy Wood wrote: Sure, I should remember to ignore it or initialize it to nil myself or have a OBBaseError macro, but one day I'll forget. The current rules make me write more and more fragile code than I'd need to if we could just all depend on setting NSError

Re: Core Data debugging

2009-07-15 Thread tmowlem
Hello, On 14 Jul 2009, at 10:01 PM, Fritz Anderson wrote: On 14 Jul 2009, at 5:14 PM, Tim Mowlem wrote: BOOL result = [moc save: err]; .. The problem is that every time I call this method the result is NO implying a failure when saving. .. The issue for this post is that when I try

Re: Core Data debugging

2009-07-14 Thread Fritz Anderson
On 14 Jul 2009, at 5:14 PM, tmow...@talktalk.net wrote: BOOL result = [moc save: err]; ... The problem is that every time I call this method the result is NO implying a failure when saving. ... The issue for this post is that when I try to examine the NSError object it is invalid. The

re: Core Data Debugging

2008-07-25 Thread Ben Trumbull
I use Core Data to store the information and it all runs pretty smoothly, that is until the app has been running for 15-20mins and I start getting Core Data save errors such as CoreData does not support persistent cross-store relationships This happens when you save objects to a store that