Sunday, May 15, 2011

NSString hasSuffix example objc

NSString:hasSuffix checks whether the given NSString object contains a specified string as its ending characters. Following code fragment shows an example of NSString:hasSuffix method. 

NSString    *str = @"start_prefix  mystring  ending_suffix";

if( [str  hasSuffix:@"ffix"] )
{
    NSLog(@"The string ends with ffix");
}