Search This Blog

Thursday, 20 November 2014

iOS Phone No Validation



-(BOOL)checkValidation :(NSString *)phoneNo
{
    NSString *phoneRegex = @"((971)\\d{9})";
    NSPredicate *phoneTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", phoneRegex];
    
    BOOL phoneValidates = [phoneTest evaluateWithObject:phoneNo];
    return phoneValidates;
    

}

Thursday, 24 July 2014

Youtube Embeded not playing in landscape mode in iOS6 and above

Just Copy and paste below code in your AppDelegate

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
    
    id presentedViewController = [window.rootViewController presentedViewController];
    NSString *className = presentedViewController ? NSStringFromClass([presentedViewController class]) : nil;
    
    if (window && [className isEqualToString:@"MPInlineVideoFullscreenViewController"]) {
        return UIInterfaceOrientationMaskAll;
    } else {
        return UIInterfaceOrientationMaskPortrait;
    }
    

}

Saturday, 12 July 2014

Play Youtube video in webview with HTML

Copy and Paste below code and load in your webview:

NSURL *myURL =[NSURL URLWithString:@"http://www.youtube.com/v/zah99ETVOz4"];

NSString *embedHTML = @"<html><head><meta name = \"viewport\" content = \"initial-scale = 1.0, user-scalable = no, width = 212\"/></head><body style=\"background:#F00;margin-top:0px;margin-left:0px\"><div><object width=\"212\" height=\"172\"><param name=\"movie\" value=\"%@\"></param><param name=\"wmode\" value=\"transparent\"></param><embed src=\"%@\"type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"320\" height=\"270\"></embed></object></div></body></html>";

NSString *html = [NSString stringWithFormat:embedHTML, myURL,myURL,myURL];





[YourWebView loadHTMLString:html baseURL:nil];

Monday, 30 June 2014

Add Event into iphone Calendar

//Add Event kit framework
EventKit.framework
//import 
#import <EventKit/EventKit.h>

//Copy below code and enjoy

-(IBAction)AddEvent:(id)sender
{
    NSString *dateString = @"Jul 09,2014 00:00";
    
    //Create a formater
    NSDateFormatter *formater =[[NSDateFormatter alloc] init];
    [formater setDateFormat:@"MMM dd,yyyy HH:mm"];
    NSDate *startDate =[formater dateFromString:dateString];
    
    NSLog(@"current date %@",[NSDate date]);
    EKEventStore *store = [[EKEventStore alloc] init];
    [store requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
        if (!granted) { return; }
        EKEvent *event = [EKEvent eventWithEventStore:store];
        event.title = @"My Birthday";
        event.startDate = startDate;//[NSDate date]; //today
        event.endDate = [event.startDate dateByAddingTimeInterval:60*60];  //set 1 hour meeting
        [event setCalendar:[store defaultCalendarForNewEvents]];
        NSError *err = nil;
        [store saveEvent:event span:EKSpanThisEvent commit:YES error:&err];
        NSString *savedEventId = event.eventIdentifier;  //this is so you can access this event later
    }];
    

}

Friday, 6 June 2014

Convert mp3 to caf format


Open terminal and go to the folder where your mp3 file is placed then write below command and enter 

afconvert -f caff -d LEI16@44100 song.mp3 song.caf

Thats all 

Thursday, 5 June 2014

Download Manager for iOS

Small effort by ideamakerz.
This download manager uses the iOS 7 NSURLSession api to download files.
  1. Can download files if app is in background.
  2. Can download multiple files at a time.
  3. It can resume interrupted downloads.
  4. User can also pause the download.
  5. User can retry any download if any error occurred during download.


You can download this amazing tool for your development from here.
Install in your device from here.


Tuesday, 3 June 2014

How to right function in swift language

func whatsYourStatus (age:Int, name:String) ->(String)
{
    var answer=""
   
    if(age < 0)
    {
        answer = "you need to born first!"
    }
    else if(age < 13)
    {
        answer = "you are not ready for programing"
    }
    else if(age >= 13 && age <= 19)
    {
        answer = "you can start programing"
    }
    else if(age > 19 && age <= 25)
    {
        answer = "you are an expert of Objective-C"
    }
    else if(age > 25 && age <= 30)
    {
        answer = "you are not ready for swift"
    }
    else if(age > 30 && age <= 35)
    {
        answer = "you are an expert of swift"
    }
    else if(age > 35)
    {
        answer="you are retired , have time with your family"
    }
    return "\(name) \(answer)"
}

whatsYourStatus(45, "Kareem")