Saturday, May 18, 2013

NSString isEqualToString example ios

[NSString isEqualToString]

Returns a Boolean value that indicates whether a given string is equal to the receiver using a literal Unicode-based comparison.
- (BOOL)isEqualToString:(NSString *)aString
The string with which to compare the receiver.
Return Value of [NSString isEqualToString]
YES if aString is equivalent to the receiver (if they have the same id or if they areNSOrderedSame in a literal comparison), otherwise NO.
Discussion of [NSString isEqualToString]
The comparison uses the canonical representation of strings, which for a particular string is the length of the string plus the Unicode characters that make up the string. When this method compares two strings, if the individual Unicodes are the same, then the strings are equal, regardless of the backing store. “Literal” when applied to string comparison means that various Unicode decomposition rules are not applied and Unicode characters are individually compared. So, for instance, “Ö” represented as the composed character sequence “O” and umlaut would not compare equal to “Ö” represented as one Unicode character.
Special Considerations
When you know both objects are strings, this method is a faster way to check equality than isEqual:.
Example of [NSString isEqualToString]
- (void)uui
  array2 = [NSMutableArray arrayWithContentsOfFile:Path2];
  string = (NSString *)[array2 objectAtIndex:3];
  NSString *string2 = @"Partly Cloudy";  
  NSString *trimmedString = [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
  NSLog(@"%@ , %@", trimmedString, string2);
   if ([trimmedString isEqualToString:string2])
Example of [NSString isEqualToString]
if ([touchClass isEqualToString:[NSString stringWithFormat:@"%@",[AnagramLetter class]]]) {
        UITouch * touch = [touches anyObject];
        CGPoint previous = [touch previousLocationInView:[touch.view superview]];
        CGPoint current = [touch locationInView:[touch.view superview]];
        CGPoint displacement = CGPointMake(current.x - previous.x, current.y - previous.y);

        CGPoint center =;
        center.x += displacement.x;
        center.y += displacement.y; = center;
Example of [NSString isEqualToString]
BOOL flag = [[lang precomposedStringWithCanonicalMapping] isEqualToString:
                    [currentLang precomposedStringWithCanonicalMapping]];