The following sets an NSString to the StringValue of a textfield. Then, the strings are compared in General_combinations
- (IBAction)SendAction:(id)sender
{
NSString *MyLoggerCommand = [CommandBox stringValue];
[CommandBox setStringValue:@""];
[[[MyLogger textStorage] mutableString] appendString: MyLoggerCommand];
[self General_Combinations];
}
- (void)General_Combinations
{
NSLog(@"General Combinations called..");
if([MyLoggerCommand isEqualToString:@"this"])
{
NSLog(@"Matched..");
}
}
However, no matter what the strings are, they are never equal.
the snippet
[CommandBox setStringValue:@""];
shouldn’t affect anything because the NSString is set first before the actual box is cleared.
The problem is you’re comparing MyLoggerCommand when the second method doesn’t know what that is. Try this code: