User Tools

Site Tools


Sidebar

Programming Reference/Librarys

Question & Answer

Q&A is closed







objective-c:foundation.framework:nsstring.h:stringwithformat

stringWithFormat

    + (id)stringWithFormat:(NSString *)format, ...    

Returns a string created by using a given format string as a template into which the remaining argument values are substituted

ObjC Sourcecode Example

    int a= 42;
 
        // string composed of single varable
 
        NSString *myString=[NSString stringWithFormat:@"the answer to life the universe and everything is %i", a];
 
        NSLog(@"MyString: %@", myString);
 
 
        //assembling of different variables
 
        NSString *myString2=@"the answer to life the universe and everything is";
 
        myString2=[NSString stringWithFormat:@"%@ %i", myString2, a];
 
        NSLog(@"MyString2: %@", myString2);    

Output for this example code

output:

 
2012-04-15 12:02:11.331 FoundationNSString[618:403] MyString: the answer to life the universe and everything is 42 
2012-04-15 12:02:11.334 FoundationNSString[618:403] MyString2: the answer to life the universe and everything is 42 
advertising
objective-c/foundation.framework/nsstring.h/stringwithformat.txt · Last modified: 2012/12/20 12:24 (external edit)

Impressum Datenschutz