Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8763739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:51:11+00:00 2026-06-13T15:51:11+00:00

my first question here. I am trying to create a simple application which takes

  • 0

my first question here.

I am trying to create a simple application which takes in a picture from one location, and places it to the desktop. The problem I’m having is this error:

2012-10-27 10:49:16.405 saveFile[3271:303] +[__NSCFConstantString scheme]: unrecognized selector sent to class 0x7fff73c01e38
    2012-10-27 10:49:16.406 saveFile[3271:303] +[__NSCFConstantString scheme]: unrecognized selector sent to class 0x7fff73c01e38

On this line:

CGImageRef imageItself =  CGImageSourceCreateImageAtIndex(myImageSource, 0, NULL);

And here’s the actual code:

Header file:

#import <Cocoa/Cocoa.h>

//NSOpenPanel = use finder
NSOpenPanel *openPanel;
//URL is the directory
NSURL*  theDoc;


//Don't allow bottom button to malfunction by being clicked early.
bool topButtonClicked = NO;

@interface saveFileAppDelegate : NSObject <NSApplicationDelegate>

- (IBAction)moveFile:(id)sender;
- (IBAction)chooseFile:(id)sender;



@property (nonatomic, retain) IBOutlet NSTextField *label;
@property (assign) IBOutlet NSWindow *window;

@end

.m file:

#import "saveFileAppDelegate.h"

@implementation saveFileAppDelegate

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    // Insert code here to initialize your application
}



- (IBAction)chooseFile:(id)sender {
    openPanel = [NSOpenPanel openPanel];
    [openPanel beginWithCompletionHandler:^(NSInteger result){
        if (result == NSFileHandlingPanelOKButton) {
            theDoc = [[openPanel URLs] objectAtIndex:0];
            [_label setStringValue:[NSString stringWithFormat:@"%@",theDoc]];
            // Open  the document.
            topButtonClicked = YES;
        }

    }
    ];
}

- (IBAction)moveFile:(id)sender {

    if (topButtonClicked == YES) {

        //Take in picture

        CGImageSourceRef myImageSource = CGImageSourceCreateWithURL((__bridge CFURLRef)(theDoc), NULL);

        //CGImageRef myImage = CGImageSourceCreateImageAtIndex(myImageSource,0,NULL);


        //Save picture to desktop

        //Save where I wish to save the file
        CFURLRef desktopURL = (CFURLRef)@"/Users/Ken/Desktop/";

        //Save where I want to save, the type of file I expect to save, number of images to save, any additional options.
        CGImageDestinationRef whereToSave = CGImageDestinationCreateWithURL(desktopURL, kUTTypeJPEG, 1, NULL);

        //Create a reference to the image itself, take in the image read, which image (only one, so 0), and additional options.
        CGImageRef imageItself =  CGImageSourceCreateImageAtIndex(myImageSource, 0, NULL);

        //Begin final preperations, pull altogether desktop URL, the image read in before, and additional options.
        CGImageDestinationAddImage (whereToSave, imageItself, NULL);

        //Finalize (write the file)
        CGImageDestinationFinalize(whereToSave);

        //CGImageDestinationRef saveImageToDesktop (CFURLRef desktop, CFStringRef jpeg, size_t count, CFDictionaryRef NULL);

    }
    else{


        /* open an alert with an OK button */
        NSAlert *alert = [[NSAlert alloc] init];
        [alert setMessageText:@"Stop it."];
        [alert runModal];
    }
}


void CGImageDestinationAddImage (CGImageDestinationRef idst, CGImageRef image, CFDictionaryRef properties);

@end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T15:51:13+00:00Added an answer on June 13, 2026 at 3:51 pm

    OP here.

    I managed to fix it. I made it a bit more abstract, and lengthened out every method as much as I could so I could see it step by step. Thought I’d post up my fix for anyone else who stumbles upon my question.

    Here is the end code for the move file section in .m:

    - (IBAction)moveFile:(id)sender {
    
        if (topButtonClicked == YES) {
    
            //Take in picture
    
            CFURLRef CFURLReftheDoc = (__bridge CFURLRef)theDoc;
    
            CGImageSourceRef myImageSource = CGImageSourceCreateWithURL(CFURLReftheDoc, NULL);
    
            //Create a reference to the image itself, take in the image read, which image (only one, so 0), and additional options.
            CGImageRef imageItself =  CGImageSourceCreateImageAtIndex(myImageSource, 0, NULL);
    
            //Save picture to desktop
    
            //Store desktop directory.
            NSString *path = [@"~/Desktop/public.png" stringByExpandingTildeInPath];
    
            NSURL *NSURLdesktopURL = [[NSURL alloc] initFileURLWithPath:path];
    
            NSLog(@"%@",NSURLdesktopURL);
    
            //store where I want to save, the type of file I expect to save, number of images to save, any additional options.
            CGImageDestinationRef whereToSave = CGImageDestinationCreateWithURL((__bridge CFURLRef)NSURLdesktopURL, kUTTypeJPEG, 1, NULL);
    
                   // NSLog(@"%@",whereToSave);
    
            //Begin final preperations, pull altogether desktop URL, the image read in before, and additional options.
            CGImageDestinationAddImage (whereToSave, imageItself, NULL);
    
            //Finalize (write the file)
            CGImageDestinationFinalize(whereToSave);
    
            //CGImageDestinationRef saveImageToDesktop (CFURLRef desktop, CFStringRef jpeg, size_t count, CFDictionaryRef NULL);
    
        }
        else{
    
    
            /* open an alert with an OK button */
            NSAlert *alert = [[NSAlert alloc] init];
            [alert setMessageText:@"Stop it."];
            [alert runModal];
        }
    }
    @end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First question here! I'm trying to create a mail system and now working on
First, here's is my rough example: http://demindu.com/sandbox/simple.html What I'm trying to do: Create a
So I decided to start using prototype and here's my first question. I'm trying
Sorry for this simple question but I am stuck here. I am trying to
First question here: it is a very short yet fundamental thing in Java that
First question here so hello everyone. The requirement I'm working on is a small
my first question here! I have a problem with a piece of code that
this is my first question here so be gentle ! recently i try to
this is my first question here :) I know that I should not check
This is my first question here so try to make my best so you

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.