• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Validating in Core Data
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Validating in Core Data
      • From: mmalcolm crawford <email@hidden>
    • Re: Validating in Core Data
      • From: Jim Correia <email@hidden>
  • Prev by Date: Helpbooks
  • Next by Date: Re: Validating in Core Data
  • Previous by thread: Re: Helpbooks
  • Next by thread: Re: Validating in Core Data
  • Index(es):
    • Date
    • Thread