Tuesday, 13 December 2011

UrlDemo 5

URLDemo5
//For the CiFaceDetection

http://maniacdev.com/2011/11/tutorial-easy-face-detection-with-core-image-in-ios-5/

//For the different example
http://iphonecode.weebly.com/second-page.html

//For the paint app reference
http://itunes.apple.com/us/app/xpaint/id388881325?mt=8
http://itunes.apple.com/us/app/doodle-touch/id398904512?mt=8

//For the Enape and MKStoreManager of the app
http://www.sixtemia.com/journal/2009/08/12/using-store-kit-framework/

//For the different snippet of the iphone
http://borkware.com/quickies/everything-by-date
http://jidh.weebly.com/iphone-development.html

//For the UUID in iphone
  CFUUIDRef cfuuid = CFUUIDCreate (kCFAllocatorDefault);
    NSString *uuid = (NSString *)CFUUIDCreateString (kCFAllocatorDefault, cfuuid);
    CFRelease (cfuuid);
    NSLog(@"%@",uuid);
//For the paint demo
http://code.google.com/p/paintboardiphone/downloads/list
http://pastebin.com/9dKPHt6R

http://www.iphonedevsdk.com/forum/iphone-sdk-development/13064-how-draw-transparent-stroke-anyway-delete-some-part-uiimage-cg.html

//For the checking of network
-(BOOL)checkNetworkConnection{
    NSString *connectingString=[[NSString alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://google.com"]];
    if ([connectingString length]==0) {
        NSLog(@"not connected");
        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Error" message:@"Network is not available " delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert show];
        [alert release];
        netWork=YES;
    }
    else {
        netWork=NO;
    }
   
    [connectingString release];
    return netWork;
}
// For the sorting of array into alphabetic order
wordArray = [[wordArray sortedArrayUsingSelector:
                       @selector(compare:)] mutableCopy];
//For the pdf demos
http://pspdfkit.com/

//For the line drawing and erasing
write it between the touch moved

UITouch *touch = [touches anyObject];   
    CGPoint currentPoint = [touch locationInView:self.colorView];
      //currentPoint.y -= 20;
        if (appDelegate.iphoneIpad==1) {
            drawPencil.frame=CGRectMake(currentPoint.x+5,currentPoint.y-30,drawPencil.frame.size.width,drawPencil.frame.size.height);       
           
        }
        else{
            drawPencil.frame=CGRectMake(currentPoint.x+10,currentPoint.y-80,drawPencil.frame.size.width,drawPencil.frame.size.height);       
           
        }
       
        if (eraseDrawImg==NO) {
                //For Drawing of line....
           
                //drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
                UIGraphicsBeginImageContext(self.colorView.frame.size);
                [drawImage.image drawInRect:CGRectMake(0, 0, drawImage.frame.size.width, drawImage.frame.size.height)];
                CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
                CGContextSetLineWidth(UIGraphicsGetCurrentContext(), eraseSize);
                
                    CGContextSetStrokeColorWithColor(UIGraphicsGetCurrentContext(),color);
               
                CGContextBeginPath(UIGraphicsGetCurrentContext());
                CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
                CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
                CGContextStrokePath(UIGraphicsGetCurrentContext());
                drawImage.image=UIGraphicsGetImageFromCurrentImageContext();
                          
                UIGraphicsEndImageContext();  
                
            } 
            else{
                //For Erasing of Drawn line....

                UIGraphicsBeginImageContext(self.colorView.frame.size);
                [drawImage.image drawInRect:CGRectMake(0, 0, drawImage.frame.size.width, drawImage.frame.size.height)];
                CGContextSetLineCap(UIGraphicsGetCurrentContext(),kCGImageAlphaNone); //kCGImageAlphaPremultipliedLast);
                CGContextSetLineWidth(UIGraphicsGetCurrentContext(), eraseSize);
                CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1, 0, 0, 10);
                CGContextAddArc(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y, eraseSize, 0.0, 2*M_PI, 0);//, 50, 50, 50, 0.0, 2*M_PI, 0);
                CGContextClip(UIGraphicsGetCurrentContext());
                CGContextClearRect(UIGraphicsGetCurrentContext(),self.colorView.frame);

                CGContextBeginPath(UIGraphicsGetCurrentContext());
                CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
                CGContextClearRect(UIGraphicsGetCurrentContext(), CGRectMake(lastPoint.x, lastPoint.y, eraseSize,eraseSize));
                
                CGContextStrokePath(UIGraphicsGetCurrentContext());
                drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
                UIGraphicsEndImageContext();
            }           
           // NSLog(@"%d",imageTag);
         NSLog(@"%@",lineArray);
        lastPoint = currentPoint;
   
        mouseMoved++;
   
    if (mouseMoved == 10) {
        mouseMoved = 0;
        }
    }

//For the Bluring to imageview

-(UIImage*)imageWithBlurAroundPoint:(CGPoint)point {
    CGRect             bnds = CGRectZero;
    UIImage*           copy = nil;
    CGContextRef       ctxt = nil;
    CGImageRef         imag = rgbImg.image.CGImage;
    CGRect             rect = CGRectZero;
    CGAffineTransform  tran = CGAffineTransformIdentity;
    int                indx = 0;
   
    rect.size.width  = CGImageGetWidth(imag);
    rect.size.height = CGImageGetHeight(imag);
   
    bnds = rect;
   
    UIGraphicsBeginImageContext(bnds.size);
    ctxt = UIGraphicsGetCurrentContext();
   
    // Cut out a sample out the image
    CGRect fillRect = CGRectMake(point.x - 10, point.y - 10, 20, 20);
    CGImageRef sampleImageRef = CGImageCreateWithImageInRect(rgbImg.image.CGImage, fillRect);
   
    // Flip the image right side up & draw
    CGContextSaveGState(ctxt);
   
    CGContextScaleCTM(ctxt, 1.0, -1.0);
    CGContextTranslateCTM(ctxt, 0.0, -rect.size.height);
    CGContextConcatCTM(ctxt, tran);
   
    CGContextDrawImage(UIGraphicsGetCurrentContext(), rect, imag);
   
    // Restore the context so that the coordinate system is restored
    CGContextRestoreGState(ctxt);
   
    // Cut out a sample image and redraw it over the source rect
    // several times, shifting the opacity and the positioning slightly
    // to produce a blurred effect
    for (indx = 0; indx < 5; indx++) {
        CGRect myRect = CGRectOffset(fillRect, 0.5 * indx, 0.5 * indx);
        CGContextSetAlpha(ctxt, 0.2 * indx);
        CGContextScaleCTM(ctxt, 1.0, -1.0);
        CGContextDrawImage(ctxt, myRect, sampleImageRef);
    }
   
    copy = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
   
    return copy;

}
//For the soap parsing demo
http://www.icodeblog.com/2008/11/03/iphone-programming-tutorial-intro-to-soap-web-services/

//For the page curl effect from left to right & vice versa
https://github.com/jemmons/PageCurl


 //For the glow of the line
    /*float glowWidth = 10.0;
     float colorValues[] = { 0, 0, 1, 1.0 };
     CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
     CGColorRef glowColor = CGColorCreate( colorSpace, colorValues );
     CGContextSetShadowWithColor( c, CGSizeMake( 0.0, 0.0 ), glowWidth, glowColor );*/

//touch and erase in uiimageview in iphone
http://www.iphonedevsdk.com/forum/iphone-sdk-development/13064-how-draw-transparent-stroke-anyway-delete-some-part-uiimage-cg.html




Friday, 18 November 2011

iphone snippet

//For the Invert of any object in iphone
UIGraphicsBeginImageContext(rgbImg.image.size);
    CGContextSetBlendMode(UIGraphicsGetCurrentContext(), kCGBlendModeCopy);
    UIImage * image=rgbImg.image;
    [image drawInRect:CGRectMake(0, 0, image.size.width, image.size.height)];
    CGContextSetBlendMode(UIGraphicsGetCurrentContext(), kCGBlendModeDifference);
    CGContextSetFillColorWithColor(UIGraphicsGetCurrentContext(),[UIColor whiteColor].CGColor);
    CGContextFillRect(UIGraphicsGetCurrentContext(), CGRectMake(0, 0, image.size.width, image.size.height));
    rgbImg.image= UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();


//For the Black & White of the image
UIImage *originalImage = rgbImg.image; // this image we get from UIImagePickerController
    CGColorSpaceRef colorSapce = CGColorSpaceCreateDeviceGray();
    CGContextRef context = CGBitmapContextCreate(nil, originalImage.size.width, originalImage.size.height, 8, originalImage.size.width, colorSapce, kCGImageAlphaNone);
    CGContextSetInterpolationQuality(context, kCGInterpolationHigh);
    CGContextSetShouldAntialias(context, NO);
    CGContextDrawImage(context, CGRectMake(0, 0, originalImage.size.width, originalImage.size.height), [originalImage CGImage]);
    CGImageRef bwImage = CGBitmapContextCreateImage(context);
    CGContextRelease(context);
    CGColorSpaceRelease(colorSapce);
    rgbImg.image = [UIImage imageWithCGImage:bwImage]; // This is result B/W image.
    CGImageRelease(bwImage);


//For the mirrored image orientation
if (mirrorOn==NO) {
       rgbImg.image = [UIImage imageWithCGImage:rgbImg.image.CGImage scale:rgbImg.image.scale orientation:UIImageOrientationUpMirrored];
       mirrorOn=YES;

    }
   else if (mirrorOn==YES) {
       mirrorOn=NO;
       rgbImg.image = [UIImage imageWithCGImage:rgbImg.image.CGImage scale:rgbImg.image.scale orientation:UIImageOrientationUp];

    }


//For the uiimage+extra classes for the brightness and contrast

https://github.com/coryleach/UIImageAdjust

//For the uiimage sepia and more

https://github.com/Nyx0uf/NYXImagesUtilities/tree/master/Categories

//For the paint in iphone

http://www.bogotobogo.com/XcodeSDK-Chapter11.html

//Dropdown in iphone
http://kshitizghimire.com.np/dropdown-in-iphoneipad/

//Lazy loading of tableview in iphone

http://kshitizghimire.com.np/lazy-loading-custom-uitableviewcell/

//TwitPic

http://www.techotopia.com/index.php/An_Example_iPhone_iOS_5_TWTweetComposeViewController_Twitter_Application

//For Image Cropping

- (UIImage*)imageByCropping:(UIImage *)imageToCrop toRect:(CGRect)rect
{
    CGImageRef imageRef = CGImageCreateWithImageInRect([imageToCrop CGImage], rect);
    UIImage *cropped = [UIImage imageWithCGImage:imageRef];
    CGImageRelease(imageRef);   
   
    return cropped;
}


//For imageview animation like crossDissolve

#import <QuartzCore/QuartzCore.h>
...
imageView.image = [UIImage imageNamed:(i % 2) ? @"3.jpg" : @"4.jpg"];

CATransition *transition = [CATransition animation];
transition.duration = 1.0f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionFade;

[imageView.layer addAnimation:transition forKey:nil];

//For memory warning issues
http://akosma.com/2009/01/28/10-iphone-memory-management-tips/

//Cook book Example
http://code.google.com/p/iphone-sdk-programming-book-code-samples/downloads/list

//Send sms from the iphone ipad
- (void)sendSMS
{
    if ([MFMessageComposeViewController canSendText])
    {
        MFMessageComposeViewController *messageView = [[MFMessageComposeViewController alloc] init];
        messageView.messageComposeDelegate = self;
       
         [self presentModalViewController:messageView animated:YES];
        [messageView release];
    }
    else {
        [appDel showAlert:@"Oops" message:@"You can't send message"];
    }
   
}
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result {
  //  SMS.hidden = NO;
    switch (result)
    {
        case MessageComposeResultCancelled:
           // SMS.text = @"Result: canceled";
            NSLog(@"Result: canceled");
            break;
        case MessageComposeResultSent:
         //   SMS.text = @"Result: sent";
            NSLog(@"Result: sent");
            break;
        case MessageComposeResultFailed:
          //  SMS.text = @"Result: failed";
            NSLog(@"Result: failed");
            break;
        default:
         //   SMS.text = @"Result: not sent";
            NSLog(@"Result: not sent");
            break;
    }
   
    [self dismissModalViewControllerAnimated:YES];
   
}

//Send mail from the iphone ipad
-(IBAction)sendEmail
{
   
    //disappear=YES;
    if([MFMailComposeViewController canSendMail] == false) {
        UIAlertView *view = [[UIAlertView alloc] initWithTitle:@"Error" message:@"The device cannot currently send email." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
        [view show];
        [view release];
        return;
    }
    else{
        Class mailClass = (NSClassFromString(@"MFMailComposeViewController"));
        if (mailClass != nil)
        {
            // We must always check whether the current device is configured for sending emails
            if ([mailClass canSendMail])
            {
                [self displayComposerSheet];
            }
            else
            {
                [self launchMailAppOnDevice];
            }
        }
        else
        {
            [self launchMailAppOnDevice];
        }
    }
   
}
-(void)displayComposerSheet
{
   
    MFMailComposeViewController *mailView = [[MFMailComposeViewController alloc] init];
    mailView.mailComposeDelegate = self;
    //SharedManager *sm = [SharedManager sharedInstance];
    [mailView setSubject:@"Hello from "];//[sm.text substringToIndex:20]];
   
    [mailView setMessageBody:@"You can know more from this url!" isHTML:YES];
   
    NSData *attachmentData = UIImageJPEGRepresentation(getImg, 1.0);
    UIImage *image=getImg;
    [mailView addAttachmentData:attachmentData mimeType:@"image/png" fileName:[NSString stringWithFormat:@"%@",image]];
     [self presentModalViewController:mailView animated:YES];
    [mailView release];
   
}


#pragma mark -
#pragma mark Workaround

// Launches the Mail application on the device.
-(void)launchMailAppOnDevice
{    
    MFMailComposeViewController *mailView = [[MFMailComposeViewController alloc] init];
    mailView.mailComposeDelegate = self;
    [mailView setSubject:@"Hello from  "];    
    [mailView setMessageBody:@"You can know more from this url!" isHTML:YES];
   
    NSData *attachmentData = UIImageJPEGRepresentation(getImg, 1.0);
    UIImage *image=getImg;
    [mailView addAttachmentData:attachmentData mimeType:@"image/png" fileName:[NSString stringWithFormat:@"%@",image]];
    [self presentModalViewController:mailView animated:YES];
    [mailView release];
   
   
   
}
- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
    // Dismiss Mail View
    [self dismissModalViewControllerAnimated:YES];
   
    switch (result)
    {
        case MFMailComposeResultCancelled:
            NSLog(@"Mail send canceled");
            self.navigationController.navigationBar.hidden =YES;
            break;
        case MFMailComposeResultSent:
            [appDel showAlert:@"Mail sent successfully." message:@"Success"];
            NSLog(@"Mail send successfully");
            break;
        case MFMailComposeResultSaved:
            [appDel showAlert:@"Mail saved to drafts successfully." message:@"Mail saved"];
            NSLog(@"Mail Saved");
            break;
        case MFMailComposeResultFailed:
            [appDel showAlert:[NSString stringWithFormat:@"Error:%@.", [error localizedDescription]] message:@"Failed to send mail"];
            NSLog(@"Mail send error : %@",[error localizedDescription]);
            break;
        default:
            break;
    }
}

// For SCListner class
https://github.com/stephencelis/sc_listener
//For mic Detection program
http://mobileorchard.com/tutorial-detecting-when-a-user-blows-into-the-mic/


//For the drawing the rectangle lines on the any object
- (void)drawRect  {
    UIGraphicsBeginImageContext(self.view.frame.size);
   
    CGContextRef currentContext = UIGraphicsGetCurrentContext();
    CGContextSetLineWidth(currentContext, 3.0); //or whatever width you want
    CGContextSetRGBStrokeColor(currentContext, 0.0, 0.0, 0.0, 1.0);
   
    CGRect myRect = CGContextGetClipBoundingBox(currentContext);
    //printf("rect = %f,%f,%f,%f\n", myRect.origin.x, myRect.origin.y, myRect.size.width, myRect.size.height);
   
    CGContextStrokeRect(currentContext, myRect);
    UIImage *backgroundImage = (UIImage *)UIGraphicsGetImageFromCurrentImageContext();
    UIImageView *myImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    [myImageView setImage:backgroundImage];
    [self.view addSubview:myImageView];
    [backgroundImage release];
   
    UIGraphicsEndImageContext();
}

//For the Border of the imageview in iphone

 [imageView.layer setBorderColor: [[UIColor redColor] CGColor]];
    [imageView.layer setBorderWidth: 2.0];

//Different Example for ios
http://projectswithlove.com/projects/

Wednesday, 5 October 2011

//For wifi driver for mac 10.6

http://www.insanelymac.com/forum/index.php?showtopic=218189


http://www.insanelymac.com/forum/index.php?act=Search&CODE=show&searchid=90d2112282c961971f33961e5ff7a55d&search_in=posts&result_type=topics&highlite=%2Blenovo

http://www.insanelymac.com/forum/index.php?showtopic=51725
Usage: unzip, open a Terminal window and type 'sudo ./bcm43xx_enabler.sh'. Reboot 

For Getting particular named images from the project

//For Getting particular named images from the project

NSMutableArray *any=[[NSMutableArray alloc] init];
    NSString *bundleRoot = [[NSBundle mainBundle] bundlePath];
    NSArray *dirContents = [[NSFileManager defaultManager] directoryContentsAtPath:bundleRoot];
    for (NSString *tString in dirContents) {
        if ([tString hasPrefix:@"Fire Type1"] && [tString hasSuffix:@".png"]) {
           
            [any addObject:tString];
           
        }
    }
    NSLog(@"%@",any);

Accessing specific folder files in iphone app

Accessing specific folder files
1. add folder with the second radio button
2. it is located at anyname.app/yourfolder


NSString *bundleRoot1 = [[NSBundle mainBundle] resourcePath];
    bundleRoot1=[bundleRoot1 stringByAppendingString:@"/Images"];
    NSArray *dirContents1 = [[NSFileManager defaultManager] directoryContentsAtPath:bundleRoot1];
    NSLog(@"dirContents1 %@",dirContents1);
   
    [self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:[dirContents1 objectAtIndex:0]]]];

Tuesday, 4 October 2011

twit Image on twitter with Share kit





 //


#import "TwitImageAppDelegate.h"
@interface TwitterMain : UIViewController<UIActionSheetDelegate> {

   
    TwitImageAppDelegate *appDel;
    IBOutlet UIButton *doneBtn;
    IBOutlet UITextField *userNameTxt;
    IBOutlet UITextField *passTxt;
    IBOutlet UIImageView *imageView;
}
-(IBAction)doneBtnPress;



//////////
#import "TwitterMain.h"
#import "SHKItem.h"
#import "SHKActionSheet.h"
#import "SHKSharer.h"
#import "SHKCustomShareMenu.h"
#import "Global.h"


BOOL checkImg;
@implementation TwitterMain

@synthesize controller,popover;




- (void)viewDidLoad
{
    [super viewDidLoad];
}

- (void)viewWillAppear:(BOOL)animated
{
    checkImg=NO;
    appDel=(TwitImageAppDelegate *)[[UIApplication sharedApplication]delegate];
    [super viewWillAppear:animated];
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
}

- (void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
}
-(IBAction)doneBtnPress{
   
    if (checkImg==NO) {
        [Global showAlert:@"! Opps" message:@"First Select the Image To Upload"];
    }
    else{
        appDel.username=userNameTxt.text;
        appDel.password=passTxt.text;
        SHKItem *item = [SHKItem image:imageView.image title:@"Selected Image"];
        //    SHKSharer *sharers;
        SHKActionSheet *as = [[SHKActionSheet alloc] initWithTitle:SHKLocalizedString(@"Share")
                                                          delegate:self
                                                 cancelButtonTitle:nil
                                            destructiveButtonTitle:nil
                                                 otherButtonTitles:nil];
        as.item = [[[SHKItem alloc] init] autorelease];
        as.item.shareType = SHKShareTypeImage;
       
        as.sharers = [NSMutableArray arrayWithCapacity:0];
        id class;
        class = NSClassFromString(@"SHKTwitter");
        [as addButtonWithTitle: [class sharerTitle]];
        [as.sharers addObject:@"SHKTwitter"];
        [NSClassFromString([as.sharers objectAtIndex:0]) performSelector:@selector(shareItem:) withObject:item];
    }
    //SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];
     //[actionSheet showFromToolbar:self.navigationController.toolbar];
}
-(BOOL)textFieldShouldReturn:(UITextField *)textField{
   
    [textField resignFirstResponder];   
   
    return YES;
}
-(IBAction)camera{
    //UIImagePickerController *controller;
    if (appDel.iphoneIpad==1) {
       
       
       
#if TARGET_IPHONE_SIMULATOR
       
        [Global showAlert:@"Camera is not available." message:@"Not Successfull"];
       
#elif TARGET_OS_IPHONE   
        if ([UIImagePickerController isSourceTypeAvailable:
             UIImagePickerControllerSourceTypeCamera])
        {
            controller = [[UIImagePickerController alloc] init]; 
            controller.sourceType = UIImagePickerControllerSourceTypeCamera; 
            controller.delegate = self; 
            //picker.allowsEditing = YES; 
            [self presentModalViewController:controller animated:YES];
            [controller release];
        }
        else {
            [Global showAlert:@"Camera is not available." message:@"Not Successfull"];
        }
       
#endif   
    }
    else if(appDel.iphoneIpad==2){
       
       
        controller = [[UIImagePickerController alloc] init];
        self.popover = [[UIPopoverController alloc] initWithContentViewController:controller];
        NSLog(@"The value of the bool is %@\n", (self.popover.popoverVisible ? @"YES" : @"NO"));
        //[self dismissPopoverAnimated:YES];
        if (self.popover.popoverVisible == YES) {
           
            [self.popover dismissPopoverAnimated:YES];
            [Global showAlert:@"FIRST CLOSE THE." message:@"PHOTO GALLARY"];
        }
       
        else {
           
            if ([UIImagePickerController isSourceTypeAvailable:
                 UIImagePickerControllerSourceTypeCamera])
            {
                controller.sourceType=UIImagePickerControllerSourceTypeCamera;
                [controller setDelegate:self];
               
                [self.popover setDelegate:self];
                [self.popover presentPopoverFromRect:CGRectMake(0.0, 0.0, 1200.0,1200.0)
                                              inView:self.view
                            permittedArrowDirections:UIPopoverArrowDirectionAny
                                            animated:YES];
                //[self.popover presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES];
            }
            else {
                [Global showAlert:@"Camera is not available." message:@"Not Successfull"];
            }
           
           
        }
    }
   
}

-(IBAction)addPhoto {

    if (appDel.iphoneIpad==1) {
        controller = [[UIImagePickerController alloc] init];
        //[controller setMediaTypes:[NSArray arrayWithObject:kUTTypeImage]];
        [controller setDelegate:self];
        [self presentModalViewController:controller animated:YES];
       
    }
    else if(appDel.iphoneIpad==2){
        controller = [[UIImagePickerController alloc] init];
        self.popover = [[UIPopoverController alloc] initWithContentViewController:controller];
       
        if ( self.popover.popoverVisible == YES) {
           
            [self.popover dismissPopoverAnimated:YES];
            [Global showAlert:@"FIRST CLOSE THE." message:@"PHOTO GALLARY"];
        }
        else {
           
            controller.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
            [controller setDelegate:self];
            [popover setPopoverContentSize:CGSizeMake(700.0f,300.0f)];
           
            //self.popover= [[UIPopoverController alloc] initWithContentViewController:controller];
            [self.popover setDelegate:self];
           
            [self.popover presentPopoverFromRect:CGRectMake(0.0, 0.0, 800.0, 400.0)
                                          inView:self.view
                        permittedArrowDirections:UIPopoverArrowDirectionAny
                                        animated:YES];   
        }
       
    }
   
}

-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
    [[picker parentViewController] dismissModalViewControllerAnimated:YES];
    [picker release];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    //    savePhotoBtn.enabled=YES;
    UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
    ///heroImgView.image=image;
    checkImg=YES;
   
    imageView.image=image;
   
    if (appDel.iphoneIpad==2) {
        [self.popover dismissPopoverAnimated:YES];
    }
    [self dismissModalViewControllerAnimated:YES];
   
   
}
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
{
    UIAlertView *alert;
   
    // Unable to save the image 
    if (error){
       
        alert = [[UIAlertView alloc] initWithTitle:@"Error"
                                           message:@"Unable to save image to Photo Album."
                                          delegate:self cancelButtonTitle:@"Ok"
                                 otherButtonTitles:nil];
    }
    else{ // All is well
        alert = [[UIAlertView alloc] initWithTitle:@"Success"
                                           message:@"Image saved to Photo Album."
                                          delegate:self cancelButtonTitle:@"Ok"
                                 otherButtonTitles:nil];
        [alert show];
        [alert release];
       
       
    }
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    // Relinquish ownership any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload
{
    [super viewDidUnload];
   
    // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
    // For example: self.myOutlet = nil;
}

- (void)dealloc
{
    [super dealloc];
}

@end

Friday, 30 September 2011

Checking white space and Trimming specific character in iphone

#define allTrim( anyobject ) [anyobject
 stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet] ]

NSString *stringname = @"   ";
if ( [allTrim( stringname ) length] == 0 ) NSLog(@"Is empty!");

Thursday, 29 September 2011

Text to Speech with flite

Api url
https://bitbucket.org/sfoster/iphone-tts/src
//For code it
https://bitbucket.org/sfoster/iphone-tts/

Different example for iphone

http://pragprog.com/titles/cdirec/source_code
http://www.codingventures.com/2008/12/useful-open-source-libraries-for-iphone-development/

http://iphoneapp-dev.blogspot.com/2011/05/this-example-shows-how-to-upload-images.html

http://www.scoop.it/t/iphone-and-ipad-development/p/5853246/show-a-custom-popover-view-within-your-ipad-app-seaside

http://iphonecode.weebly.com/iphone-learning-codes.html

http://code.google.com/p/iphone-sdk-programming-book-code-samples/

http://www.iphoneexamples.com/

http://pragprog.com/titles/cdirec/source_code

http://www.theiphonedev.com/SourceCode/tabid/143/Default.aspx
http://iphone.zcentric.com/

http://www.bogotobogo.com/XcodeSDK-Chapter12.html


Wednesday, 28 September 2011

UrlDemo2


// For the downloading the MKStoreManager

https://github.com/MugunthKumar/MKStoreKit


// Simple animation

http://www.edumobile.org/iphone/iphone-programming-tutorials/moveimage-in-iphone/


//For pinch in pinch out of uiimageview

http://www.icodeblog.com/2010/10/14/working-with-uigesturerecognizers/

//For image cropping ,transparency etc

http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/


//UIImageView Rotate, Move and Zooming and also for different example


http://w2om.com/uiimage-rotate-move-and-zooming/

//For pub reader example

https://github.com/st3fan/iphone-bookreader




Tuesday, 27 September 2011

Image view zoom in out + Rotate

//For zoom in /out + button with rotate by + - Buttons


#define degreesToRadians(x) (M_PI * x / 180.0)
#define zoomed 0.01
-(IBAction)resizeImageview:(id)sender{
   
    if([sender tag]==1){
        // holderView.frame=CGRectMake(x+3, y+4, width-6,height-8);
        holderView.transform = CGAffineTransformScale(holderView.transform, 1-zoomed, 1-zoomed);
       
    }
    else if([sender tag]==2){
        //holderView.frame=CGRectMake(x-3, y-4, width+6,height+8);       
        holderView.transform = CGAffineTransformScale(holderView.transform, 1+zoomed, 1+zoomed);
    }


}
-(IBAction)rotateImageView:(id)sender{
    if ([sender tag]==3) {
        holderView.transform = CGAffineTransformRotate(holderView.transform, degreesToRadians(-10));
       
    }
    else if([sender tag]==4){
        holderView.transform = CGAffineTransformRotate(holderView.transform, degreesToRadians(10));
       
    }   
}

Friday, 16 September 2011

Recording with saving in iphone

#import <UIKit/UIKit.h>
#import <sqlite3.h>
@class record_audio_testViewController;

@interface record_audio_testAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
    record_audio_testViewController *viewController;
    NSString *databaseName;
    NSString *databasePath;
    NSMutableArray *recoredAudioArray;
}
@property(nonatomic,retain)NSMutableArray *recoredAudioArray;
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet record_audio_testViewController *viewController;
-(void) checkAndCreateDatabase;
-(void) readEngEntryArrayFromDatabase;
-(void) updateDatabase:(NSString *)pathName;
- (void)insertIntoDatabase:(NSString *)Name;
@end



//////////////////
 #import "record_audio_testAppDelegate.h"
#import "record_audio_testViewController.h"
#import "TableFields.h"
@implementation record_audio_testAppDelegate
@synthesize recoredAudioArray;
@synthesize window;
@synthesize viewController;


- (void)applicationDidFinishLaunching:(UIApplication *)application {  
    databaseName = @"100Songs5.sqlite";
    NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDir = [documentPaths objectAtIndex:0];
    databasePath = [documentsDir stringByAppendingPathComponent:databaseName];
  
    // Execute the "checkAndCreateDatabase" function
    [self checkAndCreateDatabase];
    [self readEngEntryArrayFromDatabase];

  
    NSLog(@"%@",recoredAudioArray);
    // Override point for customization after app launch  
    [window addSubview:viewController.view];
    [window makeKeyAndVisible];
}
-(void) checkAndCreateDatabase{
    // Check if the SQL database has already been saved to the users phone, if not then copy it over
    BOOL success;
  
    // Create a FileManager object, we will use this to check the status
    // of the database and to copy it over if required
    NSFileManager *fileManager = [NSFileManager defaultManager];
  
    // Check if the database has already been created in the users filesystem
    success = [fileManager fileExistsAtPath:databasePath];
  
    // If the database already exists then return without doing anything
    if(success) return;
  
    // If not then proceed to copy the database from the application to the users filesystem
  
    // Get the path to the database in the application package
    NSString *databasePathFromApp = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:databaseName];
  
    // Copy the database from the package to the users filesystem
    [fileManager copyItemAtPath:databasePathFromApp toPath:databasePath error:nil];
  
    [fileManager release];
}

-(void) readEngEntryArrayFromDatabase {
    // Setup the database object
  

    sqlite3 *database;
    NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDir = [documentPaths objectAtIndex:0];
    databasePath = [documentsDir stringByAppendingPathComponent:databaseName];
    // Init the EngEntryArray Array
    recoredAudioArray = [[NSMutableArray alloc] init];
  
    // Open the database from the users filessytem
    if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {
        // Setup the SQL Statement and compile it for faster access
        const char *sqlStatement = "select * from RecordedAudio";
        sqlite3_stmt *compiledStatement;
        if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
            // Loop through the results and add them to the feeds array
            while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
                // Read the data from the result row
                NSString *EngEntryNm = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)];
              
                 [recoredAudioArray addObject:EngEntryNm];
              
         }
        }
        // Release the compiled statement from memory
        sqlite3_finalize(compiledStatement);
      
    }
    sqlite3_close(database);
  
}

-(void) updateDatabase:(NSString *)pathName
{
    NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDir = [documentPaths objectAtIndex:0];
    databasePath = [documentsDir stringByAppendingPathComponent:databaseName];

    sqlite3 *db ;
    sqlite3_stmt *update_statement;
    
    NSString *sqlStr = [NSString stringWithFormat:@"UPDATE RecordedAudio SET File_Name='%@' WHERE File_ID='%d'",
                        pathName];
  
    const char *sql = [sqlStr UTF8String];
    if(sqlite3_open([databasePath UTF8String], &db) == SQLITE_OK) {
      
     if (sqlite3_prepare_v2(db, sql, -1, &update_statement, NULL) != SQLITE_OK) {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"DatabaseNotAvailable", @"") message:[NSString stringWithUTF8String:sqlite3_errmsg(db)]
                                                       delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
        [alert show];  
        [alert release];
        //return NO;
    }
    }
    int success = sqlite3_step(update_statement);
    if (success == SQLITE_ERROR) {
        NSAssert1(0, @"Error: failed to insert into the database with message '%s'.", sqlite3_errmsg(db));
        //return NO;
    }
  
    sqlite3_finalize(update_statement);
    
}
- (void)insertIntoDatabase:(NSString *)Name{
    sqlite3 *database;
    NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDir = [documentPaths objectAtIndex:0];
    databasePath = [documentsDir stringByAppendingPathComponent:databaseName];
  
   /* if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {
        const char *sqlStatement;  
        sqlite3_stmt *addStmt;
      
    
            sqlStatement = "insert into RecordedAudio(File_Name) Values(?)";
     
        if(sqlite3_prepare_v2(database, sqlStatement, -1, &addStmt, NULL) != SQLITE_OK)
            NSAssert1(0, @"Error while creating add statement. '%s'", sqlite3_errmsg(database));
      
      
        sqlite3_bind_text(addStmt,1,[Name UTF8String],-1,SQLITE_TRANSIENT);
      
        if(SQLITE_DONE != sqlite3_step(addStmt))
            NSAssert1(0, @"Error while inserting data. '%s'", sqlite3_errmsg(database));
      
        sqlite3_finalize(addStmt);
      
        //Reset the add statement.
       // sqlite3_reset(addStmt);
        sqlite3_close(database);
    }*/
 
  
    sqlite3_stmt *insert_statement;
  
    if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {
        static char *sql = "insert into RecordedAudio(File_Name) Values(?)";
        if (sqlite3_prepare_v2(database, sql, -1, &insert_statement, NULL) != SQLITE_OK) {
            NSAssert1(0, @"Error: failed to prepare statement with message '%s'.", sqlite3_errmsg(database));
        }
    }
  
    sqlite3_bind_text(insert_statement,1,[Name UTF8String],-1,SQLITE_TRANSIENT);
    
    int success = sqlite3_step(insert_statement);
    // Because we want to reuse the statement, we "reset" it instead of "finalizing" it.
    sqlite3_finalize(insert_statement);
    //sqlite3_reset(insert_statement);
    insert_statement=nil;
    if (success == SQLITE_ERROR) {
        NSAssert1(0, @"Error: failed to insert into the database with message '%s'.", sqlite3_errmsg(database));
    } else {
      
    //    primarykey = sqlite3_last_insert_rowid(db);
    }
   
}


- (void)dealloc {
    [viewController release];
    [window release];
    [super dealloc];
}


@end
/////////////////


#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
#import <CoreAudio/CoreAudioTypes.h>
#import "record_audio_testAppDelegate.h"
@interface record_audio_testViewController : UIViewController <AVAudioRecorderDelegate> {

    record_audio_testAppDelegate *appDel;
    IBOutlet UIButton * btnStart;
    IBOutlet UIButton * btnPlay;
    IBOutlet UIActivityIndicatorView * actSpinner;
    BOOL toggle;
   
    //Variables setup for access in the class:
    NSURL * recordedTmpFile;
    AVAudioRecorder * recorder;
    NSError * error;
   
   
   
    AVAudioPlayer *audioPlayer;
    AVAudioRecorder *audioRecorder;
    int recordEncoding;
    enum
    {
        ENC_AAC = 1,
        ENC_ALAC = 2,
        ENC_IMA4 = 3,
        ENC_ILBC = 4,
        ENC_ULAW = 5,
        ENC_PCM = 6,
    } encodingTypes;
}


-(IBAction) startRecording;
-(IBAction) stopRecording;
-(IBAction) playRecording;
-(IBAction) stopPlaying;


@property (nonatomic,retain)IBOutlet UIActivityIndicatorView * actSpinner;
@property (nonatomic,retain)IBOutlet UIButton * btnStart;
@property (nonatomic,retain)IBOutlet UIButton * btnPlay;

- (IBAction) start_button_pressed;
- (IBAction) play_button_pressed;
@end

/////////////////

#import "record_audio_testViewController.h"


NSURL *   tempFilePath;
int countRecord;
@implementation record_audio_testViewController
@synthesize actSpinner, btnStart, btnPlay;



/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        // Custom initialization
    }
    return self;
}
*/

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/



// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
   
    appDel=(record_audio_testAppDelegate *)[[UIApplication sharedApplication]delegate];
   
    recordEncoding = ENC_AAC;

    //Start the toggle in true mode.
    toggle = YES;
    //btnPlay.hidden = YES;

    //Instanciate an instance of the AVAudioSession object.
    AVAudioSession * audioSession = [AVAudioSession sharedInstance];
    //Setup the audioSession for playback and record.
    //We could just use record and then switch it to playback leter, but
    //since we are going to do both lets set it up once.
    [audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error: &error];
    //Activate the session
    [audioSession setActive:YES error: &error];
    countRecord=1;
}




-(IBAction) startRecording
{    NSLog(@"startRecording");
   
         NSString *audioFileName=[NSString stringWithFormat:@"Record%d",countRecord];
    NSArray *dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
   
    NSString *docsDir = [dirPaths objectAtIndex:0];
   
   tempFilePath = [NSURL fileURLWithPath:[docsDir stringByAppendingPathComponent:[NSString stringWithFormat: @"%@.%@",audioFileName, @"caf"]]];
   
    NSLog(@"%@",tempFilePath);
    NSMutableDictionary* recordSetting = [[NSMutableDictionary alloc] init];
    [recordSetting setValue :[NSNumber numberWithInt:kAudioFormatAppleIMA4] forKey:AVFormatIDKey];
    [recordSetting setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey];
    [recordSetting setValue:[NSNumber numberWithInt: 2] forKey:AVNumberOfChannelsKey];
    //stringByAppendingPathComponent: [NSString stringWithFormat: @"%@.%@",audioFileName, @"caf"]]];
   
   
    recorder = [[ AVAudioRecorder alloc] initWithURL:tempFilePath settings:recordSetting error:&error];
    [recorder setDelegate:self];
   
    [recorder prepareToRecord];
   
    [recorder record];

       NSLog(@"recording");
}

-(IBAction) stopRecording
{
    
    NSURL *url =  tempFilePath;
    NSData *data = [NSData dataWithContentsOfURL:url];
    NSString *path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
    path = [path stringByAppendingString:[NSString stringWithFormat:@"Record%d",countRecord]];
    [data writeToFile:path atomically:YES];
   
    BOOL checkUpadte;
    [appDel readEngEntryArrayFromDatabase];
    NSMutableArray *checkArray=[[NSMutableArray alloc] init];
    checkArray=appDel.recoredAudioArray;
    NSLog(@"checkArray %@",checkArray);
    NSString *check=[NSString stringWithFormat:@"Record%d.caf",countRecord];
    for (int i=0; i<[checkArray count]; i++) {
       
        if ([[checkArray objectAtIndex:i] isEqualToString:check]) {
       
            checkUpadte=YES;
           
        }
        else{
            checkUpadte=NO;
            i=[checkArray count];
        }
    }
   
    if (checkUpadte==NO) {
        // insert
        [appDel insertIntoDatabase:check];//[NSString stringWithFormat:@"Record%d.caf",countRecord ]];
    }
    else{
        // update
        [appDel updateDatabase:check];//[NSString stringWithFormat:@"Record%d.caf",countRecord ]];
       
    }
    //UISaveVideoAtPathToSavedPhotosAlbum(path,self, @selector(imageSavedToPhotosAlbum: didFinishSavingWithError: contextInfo:),self);   
   
  
    countRecord+=1;
    NSLog(@"stopRecording");
    [audioRecorder stop];
    NSLog(@"stopped");
}
- (void)imageSavedToPhotosAlbum:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo {
    NSString *message;
    NSString *title;
    if (!error) {
       
        title = NSLocalizedString(@"Photo ", @"");
        message = NSLocalizedString(@"Photo Is Saved To Photo Gallary Successfully", @"");
    } else {
        title = NSLocalizedString(@"Photo Is Not Saved To Photo Gallary", @"");
        message = [error description];
    }
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title
                                                    message:message
                                                   delegate:nil
                                          cancelButtonTitle:NSLocalizedString(@"ButtonOK", @"")
                                          otherButtonTitles:nil];
    [alert show];
    [alert release];
}

-(IBAction) playRecording
{
    NSLog(@"playRecording");
    // Init audio with playback capability
    AVAudioSession *audioSession = [AVAudioSession sharedInstance];
    [audioSession setCategory:AVAudioSessionCategoryPlayback error:nil];
   
   // NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/Record1.caf", [[NSBundle mainBundle] resourcePath]]];
   // NSError *error;
    audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:tempFilePath error:&error];
    audioPlayer.numberOfLoops = 0;
    [audioPlayer play];
    NSLog(@"playing");
}

-(IBAction) stopPlaying
{
    NSLog(@"stopPlaying");
    [audioPlayer stop];
    NSLog(@"stopped");
}

- (void)dealloc
{
    [audioPlayer release];
    [audioRecorder release];
    [super dealloc];
}



/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (IBAction)  start_button_pressed{

    if(toggle)
    {
        toggle = NO;
        [actSpinner startAnimating];
        [btnStart setTitle:@"Stop Recording" forState: UIControlStateNormal ];   
        btnPlay.enabled = toggle;
        btnPlay.hidden = !toggle;
       
        //Begin the recording session.
        //Error handling removed.  Please add to your own code.
               
        //Setup the dictionary object with all the recording settings that this
        //Recording sessoin will use
        //Its not clear to me which of these are required and which are the bare minimum.
        //This is a good resource: http://www.totodotnet.net/tag/avaudiorecorder/
        NSMutableDictionary* recordSetting = [[NSMutableDictionary alloc] init];
        [recordSetting setValue :[NSNumber numberWithInt:kAudioFormatAppleIMA4] forKey:AVFormatIDKey];
        [recordSetting setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey];
        [recordSetting setValue:[NSNumber numberWithInt: 2] forKey:AVNumberOfChannelsKey];
       
        //Now that we have our settings we are going to instanciate an instance of our recorder instance.
        //Generate a temp file for use by the recording.
        //This sample was one I found online and seems to be a good choice for making a tmp file that
        //will not overwrite an existing one.
        //I know this is a mess of collapsed things into 1 call.  I can break it out if need be.
        recordedTmpFile = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent: [NSString stringWithFormat: @"%.0f.%@", [NSDate timeIntervalSinceReferenceDate] * 1000.0, @"caf"]]];
        NSLog(@"Using File called: %@",recordedTmpFile);
        //Setup the recorder to use this file and record to it.
        recorder = [[ AVAudioRecorder alloc] initWithURL:recordedTmpFile settings:recordSetting error:&error];
        //Use the recorder to start the recording.
        //Im not sure why we set the delegate to self yet. 
        //Found this in antother example, but Im fuzzy on this still.
        [recorder setDelegate:self];
        //We call this to start the recording process and initialize
        //the subsstems so that when we actually say "record" it starts right away.
        [recorder prepareToRecord];
        //Start the actual Recording
        [recorder record];
        //There is an optional method for doing the recording for a limited time see
        //[recorder recordForDuration:(NSTimeInterval) 10]
       
    }
    else
    {
        toggle = YES;
        [actSpinner stopAnimating];
        [btnStart setTitle:@"Start Recording" forState:UIControlStateNormal ];
        btnPlay.enabled = toggle;
        btnPlay.hidden = !toggle;
       
        NSLog(@"Using File called: %@",recordedTmpFile);
        //Stop the recorder.
        [recorder stop];
    }
}

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
   
    // Release any cached data, images, etc that aren't in use.
}

-(IBAction) play_button_pressed{

    //The play button was pressed...
    //Setup the AVAudioPlayer to play the file that we just recorded.
    AVAudioPlayer * avPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:recordedTmpFile error:&error];
    [avPlayer prepareToPlay];
    [avPlayer play];
   
}

- (void)viewDidUnload {
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
    //Clean up the temp file.
    NSFileManager * fm = [NSFileManager defaultManager];
    [fm removeItemAtPath:[recordedTmpFile path] error:&error];
    //Call the dealloc on the remaining objects.
    [recorder dealloc];
    recorder = nil;
    recordedTmpFile = nil;
}


@end
.xib
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="7.10">
    <data>
        <int key="IBDocument.SystemTarget">784</int>
        <string key="IBDocument.SystemVersion">10K549</string>
        <string key="IBDocument.InterfaceBuilderVersion">1306</string>
        <string key="IBDocument.AppKitVersion">1038.36</string>
        <string key="IBDocument.HIToolboxVersion">461.00</string>
        <object class="NSMutableDictionary" key="IBDocument.PluginVersions">
            <string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
            <string key="NS.object.0">301</string>
        </object>
        <object class="NSArray" key="IBDocument.IntegratedClassDependencies">
            <bool key="EncodedWithXMLCoder">YES</bool>
            <string>IBUIButton</string>
            <string>IBUIActivityIndicatorView</string>
            <string>IBUIView</string>
            <string>IBProxyObject</string>
        </object>
        <object class="NSArray" key="IBDocument.PluginDependencies">
            <bool key="EncodedWithXMLCoder">YES</bool>
            <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
        </object>
        <object class="NSMutableDictionary" key="IBDocument.Metadata">
            <bool key="EncodedWithXMLCoder">YES</bool>
            <object class="NSArray" key="dict.sortedKeys" id="0">
                <bool key="EncodedWithXMLCoder">YES</bool>
            </object>
            <reference key="dict.values" ref="0"/>
        </object>
        <object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
            <bool key="EncodedWithXMLCoder">YES</bool>
            <object class="IBProxyObject" id="372490531">
                <string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
                <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
            </object>
            <object class="IBProxyObject" id="843779117">
                <string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
                <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
            </object>
            <object class="IBUIView" id="774585933">
                <reference key="NSNextResponder"/>
                <int key="NSvFlags">274</int>
                <object class="NSMutableArray" key="NSSubviews">
                    <bool key="EncodedWithXMLCoder">YES</bool>
                    <object class="IBUIButton" id="1048870925">
                        <reference key="NSNextResponder" ref="774585933"/>
                        <int key="NSvFlags">292</int>
                        <string key="NSFrame">{{20, 20}, {280, 37}}</string>
                        <reference key="NSSuperview" ref="774585933"/>
                        <reference key="NSNextKeyView" ref="491348703"/>
                        <bool key="IBUIOpaque">NO</bool>
                        <bool key="IBUIClearsContextBeforeDrawing">NO</bool>
                        <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
                        <int key="IBUIContentHorizontalAlignment">0</int>
                        <int key="IBUIContentVerticalAlignment">0</int>
                        <object class="NSFont" key="IBUIFont" id="265054451">
                            <string key="NSName">Helvetica-Bold</string>
                            <double key="NSSize">15</double>
                            <int key="NSfFlags">16</int>
                        </object>
                        <int key="IBUIButtonType">1</int>
                        <string key="IBUINormalTitle">Begin Recording</string>
                        <object class="NSColor" key="IBUIHighlightedTitleColor" id="494537766">
                            <int key="NSColorSpace">3</int>
                            <bytes key="NSWhite">MQA</bytes>
                        </object>
                        <object class="NSColor" key="IBUINormalTitleColor">
                            <int key="NSColorSpace">1</int>
                            <bytes key="NSRGB">MC4xOTYwNzg0MyAwLjMwOTgwMzkzIDAuNTIxNTY4NjYAA</bytes>
                        </object>
                        <object class="NSColor" key="IBUINormalTitleShadowColor" id="423988075">
                            <int key="NSColorSpace">3</int>
                            <bytes key="NSWhite">MC41AA</bytes>
                        </object>
                    </object>
                    <object class="IBUIButton" id="531567224">
                        <reference key="NSNextResponder" ref="774585933"/>
                        <int key="NSvFlags">292</int>
                        <string key="NSFrame">{{20, 225}, {280, 37}}</string>
                        <reference key="NSSuperview" ref="774585933"/>
                        <reference key="NSNextKeyView" ref="100974320"/>
                        <bool key="IBUIOpaque">NO</bool>
                        <bool key="IBUIClearsContextBeforeDrawing">NO</bool>
                        <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
                        <int key="IBUIContentHorizontalAlignment">0</int>
                        <int key="IBUIContentVerticalAlignment">0</int>
                        <reference key="IBUIFont" ref="265054451"/>
                        <int key="IBUIButtonType">1</int>
                        <string key="IBUINormalTitle">stop Recording</string>
                        <reference key="IBUIHighlightedTitleColor" ref="494537766"/>
                        <object class="NSColor" key="IBUINormalTitleColor">
                            <int key="NSColorSpace">1</int>
                            <bytes key="NSRGB">MC4xOTYwNzg0MyAwLjMwOTgwMzkzIDAuNTIxNTY4NjYAA</bytes>
                        </object>
                        <reference key="IBUINormalTitleShadowColor" ref="423988075"/>
                    </object>
                    <object class="IBUIButton" id="100974320">
                        <reference key="NSNextResponder" ref="774585933"/>
                        <int key="NSvFlags">292</int>
                        <string key="NSFrame">{{20, 295}, {280, 37}}</string>
                        <reference key="NSSuperview" ref="774585933"/>
                        <reference key="NSNextKeyView"/>
                        <bool key="IBUIOpaque">NO</bool>
                        <bool key="IBUIClearsContextBeforeDrawing">NO</bool>
                        <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
                        <int key="IBUIContentHorizontalAlignment">0</int>
                        <int key="IBUIContentVerticalAlignment">0</int>
                        <reference key="IBUIFont" ref="265054451"/>
                        <int key="IBUIButtonType">1</int>
                        <string key="IBUINormalTitle">Play</string>
                        <reference key="IBUIHighlightedTitleColor" ref="494537766"/>
                        <object class="NSColor" key="IBUINormalTitleColor">
                            <int key="NSColorSpace">1</int>
                            <bytes key="NSRGB">MC4xOTYwNzg0MyAwLjMwOTgwMzkzIDAuNTIxNTY4NjYAA</bytes>
                        </object>
                        <reference key="IBUINormalTitleShadowColor" ref="423988075"/>
                    </object>
                    <object class="IBUIActivityIndicatorView" id="491348703">
                        <reference key="NSNextResponder" ref="774585933"/>
                        <int key="NSvFlags">-2147483356</int>
                        <string key="NSFrame">{{141, 65}, {37, 37}}</string>
                        <reference key="NSSuperview" ref="774585933"/>
                        <reference key="NSNextKeyView" ref="853401572"/>
                        <bool key="IBUIOpaque">NO</bool>
                        <bool key="IBUIClearsContextBeforeDrawing">NO</bool>
                        <bool key="IBUIUserInteractionEnabled">NO</bool>
                        <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
                        <int key="IBUIStyle">0</int>
                    </object>
                    <object class="IBUIButton" id="853401572">
                        <reference key="NSNextResponder" ref="774585933"/>
                        <int key="NSvFlags">-2147483356</int>
                        <string key="NSFrame">{{20, 122}, {280, 37}}</string>
                        <reference key="NSSuperview" ref="774585933"/>
                        <reference key="NSNextKeyView" ref="531567224"/>
                        <bool key="IBUIOpaque">NO</bool>
                        <bool key="IBUIClearsContextBeforeDrawing">NO</bool>
                        <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
                        <bool key="IBUIEnabled">NO</bool>
                        <int key="IBUIContentHorizontalAlignment">0</int>
                        <int key="IBUIContentVerticalAlignment">0</int>
                        <reference key="IBUIFont" ref="265054451"/>
                        <int key="IBUIButtonType">1</int>
                        <string key="IBUINormalTitle">Play Recording</string>
                        <reference key="IBUIHighlightedTitleColor" ref="494537766"/>
                        <object class="NSColor" key="IBUINormalTitleColor">
                            <int key="NSColorSpace">1</int>
                            <bytes key="NSRGB">MC4xOTYwNzg0MyAwLjMwOTgwMzkzIDAuNTIxNTY4NjYAA</bytes>
                        </object>
                        <reference key="IBUINormalTitleShadowColor" ref="423988075"/>
                    </object>
                </object>
                <string key="NSFrame">{{0, 20}, {320, 460}}</string>
                <reference key="NSSuperview"/>
                <reference key="NSNextKeyView" ref="1048870925"/>
                <object class="NSColor" key="IBUIBackgroundColor">
                    <int key="NSColorSpace">3</int>
                    <bytes key="NSWhite">MC43NQA</bytes>
                    <object class="NSColorSpace" key="NSCustomColorSpace">
                        <int key="NSID">2</int>
                    </object>
                </object>
                <bool key="IBUIClearsContextBeforeDrawing">NO</bool>
                <object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/>
                <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
            </object>
        </object>
        <object class="IBObjectContainer" key="IBDocument.Objects">
            <object class="NSMutableArray" key="connectionRecords">
                <bool key="EncodedWithXMLCoder">YES</bool>
                <object class="IBConnectionRecord">
                    <object class="IBCocoaTouchOutletConnection" key="connection">
                        <string key="label">view</string>
                        <reference key="source" ref="372490531"/>
                        <reference key="destination" ref="774585933"/>
                    </object>
                    <int key="connectionID">7</int>
                </object>
                <object class="IBConnectionRecord">
                    <object class="IBCocoaTouchOutletConnection" key="connection">
                        <string key="label">actSpinner</string>
                        <reference key="source" ref="372490531"/>
                        <reference key="destination" ref="491348703"/>
                    </object>
                    <int key="connectionID">15</int>
                </object>
                <object class="IBConnectionRecord">
                    <object class="IBCocoaTouchOutletConnection" key="connection">
                        <string key="label">btnStart</string>
                        <reference key="source" ref="372490531"/>
                        <reference key="destination" ref="1048870925"/>
                    </object>
                    <int key="connectionID">16</int>
                </object>
                <object class="IBConnectionRecord">
                    <object class="IBCocoaTouchEventConnection" key="connection">
                        <string key="label">startRecording</string>
                        <reference key="source" ref="1048870925"/>
                        <reference key="destination" ref="372490531"/>
                        <int key="IBEventType">7</int>
                    </object>
                    <int key="connectionID">20</int>
                </object>
                <object class="IBConnectionRecord">
                    <object class="IBCocoaTouchEventConnection" key="connection">
                        <string key="label">stopRecording</string>
                        <reference key="source" ref="531567224"/>
                        <reference key="destination" ref="372490531"/>
                        <int key="IBEventType">7</int>
                    </object>
                    <int key="connectionID">24</int>
                </object>
                <object class="IBConnectionRecord">
                    <object class="IBCocoaTouchEventConnection" key="connection">
                        <string key="label">playRecording</string>
                        <reference key="source" ref="853401572"/>
                        <reference key="destination" ref="372490531"/>
                        <int key="IBEventType">7</int>
                    </object>
                    <int key="connectionID">26</int>
                </object>
                <object class="IBConnectionRecord">
                    <object class="IBCocoaTouchEventConnection" key="connection">
                        <string key="label">playRecording</string>
                        <reference key="source" ref="100974320"/>
                        <reference key="destination" ref="372490531"/>
                        <int key="IBEventType">7</int>
                    </object>
                    <int key="connectionID">29</int>
                </object>
            </object>
            <object class="IBMutableOrderedSet" key="objectRecords">
                <object class="NSArray" key="orderedObjects">
                    <bool key="EncodedWithXMLCoder">YES</bool>
                    <object class="IBObjectRecord">
                        <int key="objectID">0</int>
                        <reference key="object" ref="0"/>
                        <reference key="children" ref="1000"/>
                        <nil key="parent"/>
                    </object>
                    <object class="IBObjectRecord">
                        <int key="objectID">-1</int>
                        <reference key="object" ref="372490531"/>
                        <reference key="parent" ref="0"/>
                        <string key="objectName">File's Owner</string>
                    </object>
                    <object class="IBObjectRecord">
                        <int key="objectID">-2</int>
                        <reference key="object" ref="843779117"/>
                        <reference key="parent" ref="0"/>
                    </object>
                    <object class="IBObjectRecord">
                        <int key="objectID">6</int>
                        <reference key="object" ref="774585933"/>
                        <object class="NSMutableArray" key="children">
                            <bool key="EncodedWithXMLCoder">YES</bool>
                            <reference ref="1048870925"/>
                            <reference ref="491348703"/>
                            <reference ref="853401572"/>
                            <reference ref="531567224"/>
                            <reference ref="100974320"/>
                        </object>
                        <reference key="parent" ref="0"/>
                    </object>
                    <object class="IBObjectRecord">
                        <int key="objectID">8</int>
                        <reference key="object" ref="1048870925"/>
                        <reference key="parent" ref="774585933"/>
                        <string key="objectName">Button - Begin Recording</string>
                    </object>
                    <object class="IBObjectRecord">
                        <int key="objectID">9</int>
                        <reference key="object" ref="491348703"/>
                        <reference key="parent" ref="774585933"/>
                    </object>
                    <object class="IBObjectRecord">
                        <int key="objectID">17</int>
                        <reference key="object" ref="853401572"/>
                        <reference key="parent" ref="774585933"/>
                    </object>
                    <object class="IBObjectRecord">
                        <int key="objectID">22</int>
                        <reference key="object" ref="531567224"/>
                        <reference key="parent" ref="774585933"/>
                        <string key="objectName">Button - Begin Recording</string>
                    </object>
                    <object class="IBObjectRecord">
                        <int key="objectID">27</int>
                        <reference key="object" ref="100974320"/>
                        <reference key="parent" ref="774585933"/>
                        <string key="objectName">Button - Begin Recording</string>
                    </object>
                </object>
            </object>
            <object class="NSMutableDictionary" key="flattenedProperties">
                <bool key="EncodedWithXMLCoder">YES</bool>
                <object class="NSArray" key="dict.sortedKeys">
                    <bool key="EncodedWithXMLCoder">YES</bool>
                    <string>-1.CustomClassName</string>
                    <string>-2.CustomClassName</string>
                    <string>17.IBPluginDependency</string>
                    <string>22.IBPluginDependency</string>
                    <string>27.IBPluginDependency</string>
                    <string>6.IBEditorWindowLastContentRect</string>
                    <string>6.IBPluginDependency</string>
                    <string>8.IBPluginDependency</string>
                    <string>9.IBPluginDependency</string>
                </object>
                <object class="NSMutableArray" key="dict.values">
                    <bool key="EncodedWithXMLCoder">YES</bool>
                    <string>record_audio_testViewController</string>
                    <string>UIResponder</string>
                    <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
                    <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
                    <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
                    <string>{{465, 298}, {320, 480}}</string>
                    <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
                    <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
                    <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
                </object>
            </object>
            <object class="NSMutableDictionary" key="unlocalizedProperties">
                <bool key="EncodedWithXMLCoder">YES</bool>
                <reference key="dict.sortedKeys" ref="0"/>
                <reference key="dict.values" ref="0"/>
            </object>
            <nil key="activeLocalization"/>
            <object class="NSMutableDictionary" key="localizations">
                <bool key="EncodedWithXMLCoder">YES</bool>
                <reference key="dict.sortedKeys" ref="0"/>
                <reference key="dict.values" ref="0"/>
            </object>
            <nil key="sourceID"/>
            <int key="maxID">29</int>
        </object>
        <object class="IBClassDescriber" key="IBDocument.Classes"/>
        <int key="IBDocument.localizationMode">0</int>
        <string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
        <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencies">
            <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS</string>
            <integer value="784" key="NS.object.0"/>
        </object>
        <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
            <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3</string>
            <integer value="3000" key="NS.object.0"/>
        </object>
        <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
        <int key="IBDocument.defaultPropertyAccessControl">3</int>
        <string key="IBCocoaTouchPluginVersion">301</string>
    </data>
</archive>