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

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -