Text validation using nonalphanumericSet / NSCharacterSet's

Morning all.

I’m trying to do some text validation in a simple textfield. A colleague has already done a length method, in cocoa I may add, but I’d like to have some character validation

We’ve added this to the code and it works fine when a non alphanumeric char is entered:

NSCharacterSet* nonAlphaNumericSet = [[NSCharacterSet alphanumericCharacterSet] invertedSet];
    if ([*partialString rangeOfCharacterFromSet:nonAlphaNumericSet].location != NSNotFound)
        NSLog(@"It's not alphanumeric!");

However, as usual, I’d like to do this in ASOC and am struggling

I have presently:

set beginningString to current application's NSString's stringWithString_("lalalal-")
        set endString to current application's NSCharacterSet's alphanumericCharacterSet_(beginningString)
        log endString

and am getting “unrecognised selector…”


(*)partialString is a part of Dynamic Cell Editing of NSFormatter which can be subclassed and attached to a text field
The appropriate method “ isPartialStringValid:proposedSelectedRange:originalString:originalSelectedRange:errorDescription:
is called automatically

The ASOC equivalent to check for the occurrence of characters from a particular character set is

set beginningString to current application's NSString's stringWithString_("lalalal-")
set notFoundConstant to current application's NSNotFound
set invertedAlphaSet to current application's NSCharacterSet's alphanumericCharacterSet()'s invertedSet()
set hasNonAlphanumericCharactersInString to beginningString's rangeOfCharacterFromSet_(invertedAlphaSet)'s location is not notFoundConstant
log hasNonAlphanumericCharactersInString