Showing posts with label NSString stringWithFormat. Show all posts
Showing posts with label NSString stringWithFormat. Show all posts

Saturday, May 14, 2011

NSString stringWithFormat example objc

Following code fragment shows how to use NSString:stringWithFormat method. stringWithFormat method performs the same work as C's printf() function. The object created by stringWithFormat is auto-released. Please note that you should prefix @ to all Objective-C strings.


NSString *urlString = [NSString stringWithFormat:@"%@/accounts/%d/apps/%d/dev-msgs", ILIME_BASE_URL, ILIME_ACCOUNT_ID, ILIME_APP_ID];
NSString *sendMessage = [NSString stringWithFormat:messageText.text];
NSString *requestBody = [NSString stringWithFormat:@"%@< notificationRequest>", sendMessage]; NSURL* url = [NSURL URLWithString:urlString]; [self postMessage:requestBody toURL:urlString];