There used to be a method to check if an application was purchased from the App Store, to protect against cracking:
NSBundle *bundle = [NSBundle mainBundle];
NS
While not a check to see if an Application was purchased from the App Store, I use this code to check to see if my application is running on a jailbroken device:
+(BOOL)isJailbroken {
NSURL* url = [NSURL URLWithString:@"cydia://package/com.example.package"];
return [[UIApplication sharedApplication] canOpenURL:url];
}