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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:44:51+00:00 2026-06-05T09:44:51+00:00

I am new to objetive-c as I came from Java (Android) and then a

  • 0

I am new to objetive-c as I came from Java (Android) and then a little of AppleScript.

So my app is making a git commit. BUT as you know the terminal has output that the user may want to see. So should I continue to use my NSTask for behind the scenes stuff, or should I just use AppleScript and let the user carry on from the terminal. Mainly my push.m looks like this :

#import "Push.h"

@implementation Push

@synthesize test;
@synthesize dirPath;


-(IBAction)chooseFolder:(id)sender{

    dirPath = [self get];
    NSArray *array = [dirPath componentsSeparatedByString:@"/"];
    NSString *pub = [array lastObject];
    [projectName setStringValue:pub];

    BOOL fileyn = [self check:dirPath];

    if(fileyn) {

    } else {

    }

}
-(IBAction)pushAction:(id)sender {
    [self push];
    [self push];
}

-(void)push{ 

    if(dirPath == nil || dirPath == @"") {
        [self chooseFolder:nil];
    }

    NSString *commitText = [commitMessage stringValue];
    [commitMessage setStringValue:@""];
    commitText = [NSString stringWithFormat:@"%@",commitText];

    if (i == 1) {

    } else {
        [self runScript:dirPath:@"add" :@"*" :nil];
        [self runScript:dirPath:@"commit" :@"-m" :commitText];
        [self runScript:dirPath:@"push" :@"origin" :@"HEAD"];
    }

}

-(void) runScript:(NSString *) path:(NSString* )cmd1:(NSString *) cmd2:(NSString *) cmd3{

    NSTask *aTask = [[NSTask alloc] init];

    NSPipe *pipe;
    pipe = [NSPipe pipe];
    [aTask setStandardOutput: pipe];

    NSFileHandle *file;
    file = [pipe fileHandleForReading];

    NSArray* args = [NSArray arrayWithObjects:cmd1,cmd2,cmd3, nil];
    [aTask setArguments:args];
    [aTask setCurrentDirectoryPath:path];
    [aTask setLaunchPath:@"/usr/local/git/bin/git"];
    [aTask setArguments:args];
    [aTask launch];

    [finished setStringValue:@"finished"];

}

-(IBAction)back:(id)sender{

    test = [[NSWindowController alloc] initWithWindowNibName:@"POP"];
    [test showWindow:self];
    [window close];

}


-(BOOL)check:(NSString *) pow{
    BOOL isFile = [[NSFileManager defaultManager] fileExistsAtPath:pow isDirectory:NO];

    return isFile;
}


-(NSString *)get {  

    NSOpenPanel *panel = [NSOpenPanel openPanel];
    [panel setAllowsMultipleSelection:NO];
    [panel setCanChooseDirectories:YES];
    [panel setCanChooseFiles:NO];
    if ([panel runModal] != NSFileHandlingPanelOKButton) return nil;
    return  [[panel directoryURL] path];
}

@end

So what should I do? Any thing to improve? Thanks in advance!

  • 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-05T09:44:53+00:00Added an answer on June 5, 2026 at 9:44 am

    This sort of application design is really up to you; there’s no right answer here. It depends on what you’re trying to accomplish, and what you’d like to allow the user to do. If you simply want to show users the output of whatever commands you’re running, you can simply get the output out of the NSTask (using the output pipe you set) and display it in a text view for the user to look through.

    However, if you want to run interactive git commands, that gets a little bit more complicated. I’m going on a limb here since your question wasn’t very specific about what ‘let the user carry on from the terminal’ means, so if this isn’t what you meant, then let me know. In terms of good user interface and user experience, unless you have no other choice, it’s almost never a good idea to force someone to go to a different app to keep using your own. If an app wants to display results to a user, it’s best to do it in-app (with a custom view, or a web view, for instance), not to drive the user elsewhere. If you want the commands to be interactive, its far better design to come up with an interface for handling that in your app versus running an AppleScript and directing users to the terminal to see and do things.

    Anyway, at a quick glance, your code seems like it should work (except for the aforementioned problems in the comments, which you should fix) — and since you hadn’t mentioned any problems with it, I assume it does. This isn’t a programming problem; it’s a design one, and one you’ll have to consider the answers to it yourself (and, that being said, I’m voting to close this question since it doesn’t really fit into the StackOverflow guidelines — the answer is a matter of opinion, not of facts).

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

Sidebar

Related Questions

I came from a java background, and I was trying to use protocol like
I'm new to Windows Phone and C#, enjoying the change from Objective-C and Java.
I'm relatively new to Objective-C and really don't know much about it yet, so
I am new to Objective-C and I am a little curious about how I
I'm new to Objetive-C and need some help, I have an Array with 22
I made a new project in XCode (console application). Then I added a new
New to Objective-C iPhone/iPod touch/iPad development, but I'm starting to discover lots of power
(New to Objective-C, but well versed in C/C++). Presently I have an Objective-C class
I'm fairly new to Objective-C and I was working with NSDictionaries today and came
I was beginning to design a new game for the iPad and I came

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.