Validating in Core Data
Validating in Core Data
- Subject: Validating in Core Data
- From: Jeff LaMarche <email@hidden>
- Date: Tue, 9 Aug 2005 16:14:17 -0400
I've written a subclass of NSManagedObject, and have implemented a
custom validation method for on attribute. I'm getting a
EXC_BAD_ACCESS (SIGSEGV) when I try and save this field:
-(BOOL)validateUrl:(NSString *)urlString error:(NSError **)error
{
if (urlString == nil)
return YES;
if ([urlString length]==0)
return YES;
NSURL *url = [NSURL URLWithString:urlString];
if (url == nil)
{
*error = [[[NSError alloc] initWithDomain:NSURLErrorKey
code:-1
userInfo:nil] autorelease];
return NO;
}
return YES;
}
urlString is not nil, but when I call [urlString length], I get the
bad access error. I used Apple's Model Object Implementation Guide
when doing this, and can't see where the gotcha might be. The
attribute, url, is a simple string that I'm simply trying to require
that it be a properly formed URL.As of this point, with the exception
of this validation method, I am letting NSManagedObject do
everything. I'm stumped... does anyone know why I'm getting this? Do
I need to retain urlString at the beginning of the method??
TIA,
Jeff
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden