Reputation: 7570
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 :))
Upvotes: 1
Views: 82
Reputation: 7570
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!
Upvotes: 1