Click here to Skip to main content
15,867,453 members
Home / Discussions / Objective-C and Swift
   

Objective-C and Swift

 
QuestionCan anyone help me solve this project? Pin
Member 115772012-Apr-15 13:46
Member 115772012-Apr-15 13:46 
AnswerRe: Can anyone help me solve this project? Pin
Sascha Lefèvre2-Apr-15 14:23
professionalSascha Lefèvre2-Apr-15 14:23 
AnswerRe: Can anyone help me solve this project? Pin
Dennis E White11-Apr-15 9:32
professionalDennis E White11-Apr-15 9:32 
AnswerRe: Can anyone help me solve this project? Pin
Peter Webb5-May-15 3:30
Peter Webb5-May-15 3:30 
QuestionLaunch Safari from another app then Autofill username and password Pin
picardy8-Jan-15 8:45
picardy8-Jan-15 8:45 
AnswerRe: Launch Safari from another app then Autofill username and password Pin
Dennis E White27-Jan-15 5:11
professionalDennis E White27-Jan-15 5:11 
AnswerRe: Launch Safari from another app then Autofill username and password Pin
C3D130-Jan-15 3:46
professionalC3D130-Jan-15 3:46 
QuestionStart java program from Objective C code Pin
DraqueD5-Jan-15 8:42
DraqueD5-Jan-15 8:42 
I'm trying to make a pretty simple frontend program that's able to start up a java program when it's run, but haven't yet mastered OC. Someone suggested that I try using a console command (code below), but I haven't been able to make that work yet.

Is there an easier way to do this, or does any one here know where my code has gone wrong?

C#
int main(int argc, const char * argv[]) {

    NSFileManager *filemgr;
    NSString *currentpath;

    filemgr = [[NSFileManager alloc] init];

    currentpath = [filemgr currentDirectoryPath];

    NSPipe *pipe = [NSPipe pipe];
    NSFileHandle *file = pipe.fileHandleForReading;

    NSTask *task = [[NSTask alloc] init];
    task.launchPath = [currentpath stringByAppendingString:@"/java"];
    task.arguments = @[@"-jar", @"PolyGlot.jar"], [NSString stringWithFormat:@"%c", argv]];
    task.standardOutput = pipe;

    [task launch];

    NSData *data = [file readDataToEndOfFile];
    [file closeFile];

    NSString *grepOutput = [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding];
    NSLog (@"grep returned:\n%@", grepOutput);

    return 0;
}


When I run this, I get the error:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'launch path not accessible'

I know that the current path is accessible, though... so I'm kind of stumped here. Any help would be much appreciated. Thanks!
AnswerRe: Start java program from Objective C code Pin
jschell5-Jan-15 9:37
jschell5-Jan-15 9:37 
GeneralRe: Start java program from Objective C code Pin
DraqueD5-Jan-15 9:52
DraqueD5-Jan-15 9:52 
AnswerRe: Start java program from Objective C code Pin
Richard MacCutchan5-Jan-15 22:39
mveRichard MacCutchan5-Jan-15 22:39 
GeneralRe: Start java program from Objective C code Pin
DraqueD6-Jan-15 5:04
DraqueD6-Jan-15 5:04 
GeneralRe: Start java program from Objective C code Pin
Richard MacCutchan6-Jan-15 5:29
mveRichard MacCutchan6-Jan-15 5:29 
GeneralRe: Start java program from Objective C code Pin
DraqueD6-Jan-15 5:43
DraqueD6-Jan-15 5:43 
GeneralRe: Start java program from Objective C code Pin
Richard MacCutchan6-Jan-15 6:29
mveRichard MacCutchan6-Jan-15 6:29 
GeneralRe: Start java program from Objective C code Pin
DraqueD6-Jan-15 9:29
DraqueD6-Jan-15 9:29 
AnswerRe: Start java program from Objective C code Pin
seemajoshii27-Feb-15 1:22
seemajoshii27-Feb-15 1:22 
QuestionHow do I find Objective C developers? Pin
Waffleapp13-Dec-14 7:13
Waffleapp13-Dec-14 7:13 
QuestionIn objective-c I’m try to create a statement that toggles a variable Pin
Member 1125124020-Nov-14 11:02
Member 1125124020-Nov-14 11:02 
AnswerRe: In objective-c I’m try to create a statement that toggles a variable Pin
Richard MacCutchan20-Nov-14 21:56
mveRichard MacCutchan20-Nov-14 21:56 
QuestionDifference between C and Objective-C Pin
online visit9-Jun-14 19:32
online visit9-Jun-14 19:32 
AnswerRe: Difference between C and Objective-C Pin
future20159-Jun-14 20:57
future20159-Jun-14 20:57 
GeneralRe: Difference between C and Objective-C Pin
online visit9-Jun-14 21:31
online visit9-Jun-14 21:31 
AnswerRe: Difference between C and Objective-C Pin
Richard MacCutchan9-Jun-14 21:00
mveRichard MacCutchan9-Jun-14 21:00 
GeneralRe: Difference between C and Objective-C Pin
thatraja10-Jun-14 21:11
professionalthatraja10-Jun-14 21:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.