ios - how to check NSString format from UIPasteBoard -
i allowing user copy registration key website, nsstirng saved clipboard , when application opens registration dialog check clipboard right away using code -
nsstring *registrationcode = [uipasteboard generalpasteboard].string;
now have value pasteboard want check format.. should aaaa-aaaa-aaaa-aaaa in essance no numbers, no spaces (including @ front , end), no lower case, no special characters... uppercase characters. how achive this?
try doing in code:
nscharacterset * everythingthatsallowedset = [nscharacterset charactersetwithcharactersinstring: @"abcdefghijklmnopqrstuvwxyz-"]; nscharacterset * charactersetfromregistrationcode = [nscharacterset charactersetwithcharactersinstring: registrationcode]; if([everythingthatsallowedset issupersetofset: charactersetfromregistrationcode ] == yes) nslog( @"this valid registration code"); else { // if there characters in registration code aren't members of // everythingallowed set, "issupersetofset" test fail nslog( @"this has invalid characters"); }
Comments
Post a Comment