Sunday, May 19, 2013

NSString stringByAppendingFormat example ios


[NSString stringByAppendingFormat]

Returns a string made by appending to the receiver a string constructed from a given format string and the following arguments.
- (NSString *)stringByAppendingFormat:(NSString *)format ...
Parameters
format
A format string. See “Formatting String Objects” for more information. This value must not be nil.

Important: Raises an NSInvalidArgumentException if format is nil.
...
A comma-separated list of arguments to substitute into format.
Return Value of [NSString stringByAppendingFormat]
A string made by appending to the receiver a string constructed from format and the following arguments, in the manner of stringWithFormat:.
Example of [NSString stringByAppendingFormat]
NSString *myString = @"some text";
myString = [myString stringByAppendingFormat:@" = %d", 3];
Example of [NSString stringByAppendingFormat]
NSString *aString  = self.stringName;
NSString * tempStr = [NSString stringWithFormat:@"%@",aString];
NSString *resultString =[name stringByAppendingFormat:tempStr];
Example of [NSString stringByAppendingFormat]
NSString   *selectDay=@"Wed 14 May";
    int yearNumber=2011;
    selectDay=[selectDay stringByAppendingFormat:[NSString stringWithFormat:@"%d", yearNumber]];
    NSLog(@"%@",selectDay);