My code:
stringFromRecievedData =
[[NSString alloc]initWithData:_data1 encoding:NSUTF8StringEncoding];
if (![stringFromRecievedData isEqualToString:lastStringFromRecievedData]) {
[lastStringFromRecievedData setString: stringFromRecievedData];
I get the same “not equal” result even in the second round- even when it is the same data each time…
Is this the correct way to compare the two?
Thanks.
If
lastStringFromRecievedDatais an instance ofNSString(or subclass such asNSMutableString), then this is the correct way to compare two strings. In this case something else may be causing your strings to not be equal.However, it looks like
lastStringFromRecievedDatais a some other object because you are callingsetString:on it. If this is the case, you need to get the string from that object first.