Capitalize in Objective C

Published on 03 October 2020 (Updated: 03 October 2020)

Welcome to the Capitalize in Objective C page! Here, you'll find the source code for this program as well as a description of how the program works.

Current Solution

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
  @autoreleasepool {
    NSLog(@"Enter the text to be capitalized: ");
    NSString* textFromStdin = [[NSString alloc] initWithData:[[NSFileHandle fileHandleWithStandardInput] availableData] encoding:NSUTF8StringEncoding];
    NSString* normalizedText = [textFromStdin stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]];
    if([normalizedText length] < 1){
      NSLog(@"Usage: please provide a string");
      return 0;
    NSString *firstChar = [[normalizedText substringToIndex:1] uppercaseString];
    NSString *remainingText = [normalizedText substringFromIndex:1];
    NSString *capitalizedText = [firstChar stringByAppendingString:remainingText];
    NSLog(@"%@", capitalizedText);
    return 0;
  return 0;

Capitalize in Objective C was written by:

If you see anything you'd like to change or update, please consider contributing.

How to Implement the Solution

No 'How to Implement the Solution' section available. Please consider contributing.

How to Run the Solution

No 'How to Run the Solution' section available. Please consider contributing.