Powered By Blogger
Showing posts with label NSPredicate. Show all posts
Showing posts with label NSPredicate. Show all posts

Monday, January 7, 2013

NSPredicate to filter data in iPhone

Hi,
Please check the below lines for filtering a content of an array using "NSPredicate".

Example:

//For Boolean value checking in Array containing dictionaries.
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(isCheck == %@)",@"true"];
NSArray *filterArr = [tmpArray filteredArrayUsingPredicate:predicate];

NSPredicate *filter = [NSPredicate predicateWithFormat:[NSString stringWithFormat:@"ServiceLevel = '0'"]];        
NSArray *filteredArray = [[tmpArray filteredArrayUsingPredicate:filter]copy];











Thanks

Tuesday, June 5, 2012

How to check valid email address in iPhone SDK?

Using the below function , you can check email address format validity. Hope , this will help you.
 
+(BOOL)checkEmailAddress:(NSString *)strEmail
{
    NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+.[A-Za-z]{2,4}";  
    NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];  
    return [emailTest evaluateWithObject:strEmail];
}


If any one has query then place you it over here.

Thanks and Regards,
Nilesh Prajapati