no visible @interface for 'UIImagePickerController

So my code says

no visible @interface for UIImagePicker Controller

I am using a Tab View Controller
My code for my FirstViewController.m is

#import "FirstViewController.h"
@interface FirstViewController () <UIImagePickerControllerDelegate, UINavigationControllerDelegate> {
UIImagePickerController *bailey;
UIImagePickerController *baileys;
UIImage *image;
IBOutlet UIImageView *imageView;
-  (IBAction)takePhoto;
-  (IBAction)chooseExisting;
@implementation FirstViewController
 - (IBAction)takePhoto {
bailey = [[UIImagePickerController alloc]init];
bailey.delegate = self;
[bailey setSourceType:UIImagePickerControllerSourceTypeCamera];
[self presentViewController:bailey animated:YES completion:NULL];
- (IBAction)chooseExisting {
baileys = [[UIImagePickerController alloc] init];
baileys.delegate = self;
[baileys setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[self presentViewController:baileys animated:YES completion:NULL];
- (void) imagePickerController:(UIImagePickerController *)picker                 didFinishPickingMediaWithInfo:(NSDictionary *)info {
image = [info objectForKey:UIImagePickerControllerOriginalImage];
[imageView setImage:image];
[self dismissViewControllerAnimated:YES completion:NULL];
- (void) imagePickerControllerDidCancel:(UIImagePickerController *)bailey {
[self dismissViewControllerAnimated:YES completion:NULL];
- (IBAction)ShareFB {
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
    slComposeViewController = [SLComposeViewController     composeViewControllerForServiceType:SLServiceTypeFacebook];
    [slComposeViewController addImage:[UIImage imageNamed:@"image"]];
    [slComposeViewController addURL:[NSURL URLWithString:@""]];
    [self presentViewController:slComposeViewController animated:YES completion:NULL];
    //I borrowed these lines of code from
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,     NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *appFile = [documentsDirectory stringByAppendingString:@"upload.png"];
    NSString *upLoad = [documentsDirectory stringByAppendingString:@"upload.png"];
    NSData *myData = [[NSData alloc]initWithContentsOfFile:appFile];
    //Here is the line that fails
    [bailey addAttachmentData:myData mimeType:@"image/png" fileName:@"upload"];
    //Up to here are the borrowed code lines.
    else {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No Facebook Account     Detected" message:@"There are no Facebook Accounts Detected. You can configure them in Settings." delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
    [alert show];

- (void)viewDidLoad
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.

- (void)didReceiveMemoryWarning
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.

And my code for my FirstViewController.h is

#import <UIKit/UIKit.h>
#import <Social/Social.h>
 @interface FirstViewController : UIViewController {SLComposeViewController    *slComposeViewController;
UIImage *upLoad;}
- (IBAction)ShareFB;

My app is designed to Take a photo and display the photo (and it does that) and then save that image to the local documents folder on the app (which I got from another post) and then specify that image to upload to Facebook (which I have)

All that works except the saving to a local documents.

1 Solution

You can store like this,

   NSString *imageFilePath = [NSString stringWithFormat:@"%@/%@",[self localPathForImage],@"upload.png"];

    UIImage *image = [UIImage imageNamed:@"image"];
    NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(image)];
    [imageData writeToFile:imageFilePath atomically:YES];

-(NSString *)localPathForImage
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
        NSString *documentsDirectory = [paths objectAtIndex:0]; // Get documents folder
        NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:@"Images"];

        if (![[NSFileManager defaultManager] fileExistsAtPath:dataPath])
            [[NSFileManager defaultManager] createDirectoryAtPath:dataPath withIntermediateDirectories:NO attributes:nil error:nil]; 

        return dataPath;