1

I'm currently trying to compare a shell output to a string. But it won't work at all!

StringOne = [[NSString alloc] initWithData:dataTwo encoding:NSUTF8StringEncoding];
if([StringOne isEqualToString:@"get if addr en0 failed, (os/kern) failure"])
{
    NSLog(@"Failure!");
}

The dataTwo is returned by a NSData from NSPipe. I tried almost everything and couldn't find anything on the internet on that.

Maybe you can help me. Thanks!

EDIT It just turned out, that the output string, I'm trying to compare, is with newline. Hpf… I just added "\n" at the end to my compare-string and it worked!

Wo should all learn from that: Check your stuff twice before posting on the net :))

Julian F. Weinert
  • 7,474
  • 7
  • 59
  • 107
  • please post your solution as an answer, and then accept that answer. (It's all perfectly legal). You'll gain reputation points, and people that scan for unanswered questions won't have to waste their time. Good luck! – shellter Nov 17 '11 at 16:36

1 Answers1

1

It turned out, that my shell output had a newline at the end. I just added "\n" to my compare string:

[StringOne isEqualToString:@"get if addr en0 failed, (os/kern) failure\n"]

Now it works!

Julian F. Weinert
  • 7,474
  • 7
  • 59
  • 107