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 6086009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:42:12+00:00 2026-05-23T11:42:12+00:00

I am working on an encryption tool, and I have a file chooser that

  • 0

I am working on an encryption tool, and I have a file chooser that a user can go into to select a file to encrypt. My problem is fairly easy. After the user clicks the “select” button in the file chooser, the filename must be returned to a label on the application. The problem is that I can’t enter the window which holds the select button to connect to the IBAction. How can I return the filename to that label after the user clicks select? Can someone perhaps upload the code that would do that? I am kind of a noob right now, so please talk in simple terms… Step by step instruction would be greatly appreciated

Thanks so much

The following is the code for the file selector:

- (IBAction)fileChooser:(id)sender {
int i;
NSOpenPanel* openDlg = [NSOpenPanel openPanel];
[openDlg setCanChooseFiles:YES];
[openDlg setCanChooseDirectories:YES];
[openDlg setPrompt:@"Select"];
if ([openDlg runModalForDirectory:nil file:nil] == NSOKButton )
{
    NSArray* files = [openDlg filenames];
    for( i = 0; i < [files count]; i++ )
    {
        [files objectAtIndex:i];

    }

}

}

  • 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-05-23T11:42:12+00:00Added an answer on May 23, 2026 at 11:42 am

    “return the filename to that label” doesn’t make sense. A function or method returns a value only to the function or method that called it; that is the only thing “return” ever means in C and Objective-C. Moreover, when a function or method returns, it ends. It is no longer running. It returns control of the program to the function or method that called it.

    So returning a value from a loop would not make sense here (the method would only process the first filename), and returning a value “to [an object]” makes no sense.

    You need to create an outlet to the field (a label is a kind of NSTextField) in the class that implements fileChooser:, and hook that outlet up in the nib editor. Then you can use that outlet to tell the field to set its stringValue.

    (Important note: Unlike in Cocoa Touch, most AppKit classes do not use formal properties. You will have to send the field a setStringValue: message.)

    Outlets are covered by the Cocoa Fundamentals Guide, and you can find the NSTextField documentation in the AppKit framework reference.

    One other thing: Since it is possible and quite reasonable for the user to select multiple files, you should handle that case. Simply setting the text field’s string value to each filename in turn will leave it showing only the last filename in the array—not really much different from setting it to the first filename and returning. Once you get the text field working, you should replace it with a table view.

    If, on the other hand, you don’t want to support multiple files, then (1) why? and (2) consider setting the open panel to disallow multiple selection. (See my answer on your previous question for documentation references in that direction.) Then you can assume that, when the response is “OK”, the filenames array contains exactly one item, and cut out the loop entirely.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am working on an encryption algorithm and i have a type problem i
I am working on a compressing and encryption system and I have run into
I am working on SQLite File Encryption . I have added sqlCipher & crypto
I am working on PGP encryption/decryption using 'bouncycastle'. Do encrypt I understand that i
I have a working test of a hardware device that uses RSA encryption, in
I'm working on a fairly complex project, a custom encryption routine if you will
I'm working on a bug where I have an MFC application that does weird
Does anybody have any working example of RSA encryption with OpenSSL.NET ? I want
Just working on a algorithm and so far i can encrypt and decrypt a
I was working on some encryption/decryption algorithms and I noticed that the encrypted byte[]

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.