0Pricing
Objective-C iOS Development for Legacy & Enterprise Apps · Lezione

Lavorare con NSString e i tipi Foundation

Impari a usare le classi Foundation principali di Objective-C — NSString, NSArray e NSDictionary — per gestire testo e collezioni nelle app iOS legacy.

Lavorare con NSString e i tipi Foundation è una lezione Objective-C iOS Development for Legacy & Enterprise Apps gratuita su CoddyKit. Questa è la lezione 4 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento Objective-C iOS Development for Legacy & Enterprise Apps, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso Objective-C iOS Development for Legacy & Enterprise Apps include 4 lezioni in totale.

Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.

The Foundation Framework

Beyond primitives, Objective-C leans on the Foundation framework for rich objects — most often NSString, NSArray, and NSDictionary.

Creating NSStrings

The @ literal builds an NSString — a full object with many helper methods, unlike a bare C string.

NSString *name = @"Ada Lovelace";
NSLog(@"Name: %@", name);

Common String Methods

NSString ships with handy methods: length, uppercaseString, stringByAppendingString:, and hasPrefix:.

NSString *greeting = [@"Hello, " stringByAppendingString:name];
NSUInteger len = greeting.length;

Formatting Strings

Build dynamic text with stringWithFormat:. The %@ token prints any object.

int score = 42;
NSString *msg = [NSString stringWithFormat:@"%@ scored %d", name, score];

Mutable Strings

NSString is immutable, so to edit text in place reach for NSMutableString.

NSMutableString *buffer = [NSMutableString stringWithString:@"Hi"];
[buffer appendString:@" there"];

NSArray Basics

NSArray is an ordered, immutable list created with the @[] literal, indexed from zero.

NSArray *colors = @[@"red", @"green", @"blue"];
NSString *first = colors[0];
NSUInteger count = colors.count;

NSMutableArray

When the list changes at runtime, use NSMutableArray with addObject: and removeObject:.

NSMutableArray *items = [NSMutableArray array];
[items addObject:@"apple"];
[items removeObjectAtIndex:0];

NSDictionary Basics

NSDictionary stores key-value pairs, built with the @{} literal and read by key.

NSDictionary *user = @{@"name": @"Ada", @"age": @36};
NSString *n = user[@"name"];

NSNumber Boxing

Collections hold objects, not primitives, so wrap numbers in NSNumber with @, then unbox via intValue.

NSNumber *boxed = @42;
int raw = [boxed intValue];

Iterating Collections

Walk any collection cleanly with Objective-C's fast enumeration for-in loop.

for (NSString *color in colors) {
  NSLog(@"%@", color);
}

Why Foundation Matters

Nearly every legacy iOS API takes or returns Foundation types, so fluency here is essential before touching UIKit or networking.

Quick Check

Test your Foundation knowledge.

Recap

Recap: NSString (and mutable variant) for text, stringWithFormat for dynamic strings, NSArray and NSDictionary for collections, and NSNumber to box primitives.

Domande Frequenti

La lezione «Lavorare con NSString e i tipi Foundation» è gratuita?

Sì — il testo completo di «Lavorare con NSString e i tipi Foundation» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso Objective-C iOS Development for Legacy & Enterprise Apps, passa a CoddyKit PRO. Il corso Objective-C iOS Development for Legacy & Enterprise Apps include 4 lezioni in totale.

Cosa imparerò in «Lavorare con NSString e i tipi Foundation»?

Impari a usare le classi Foundation principali di Objective-C — NSString, NSArray e NSDictionary — per gestire testo e collezioni nelle app iOS legacy. Eserciti Objective-C iOS Development for Legacy & Enterprise Apps con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.

Ho bisogno di esperienza per iniziare Objective-C iOS Development for Legacy & Enterprise Apps?

Non è richiesta alcuna esperienza precedente. Objective-C iOS Development for Legacy & Enterprise Apps su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 4 di 4.

Quanto tempo richiede la lezione «Lavorare con NSString e i tipi Foundation»?

La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.

Posso scrivere ed eseguire codice in questa lezione Objective-C iOS Development for Legacy & Enterprise Apps?

Sì. Ogni lezione Objective-C iOS Development for Legacy & Enterprise Apps include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.

Tutte le lezioni di questo corso

  1. Introduzione a Objective-C
  2. Sintassi e tipi di dati di base
  3. Configurazione di Xcode per Objective-C
  4. Lavorare con NSString e i tipi Foundation
← Torna a Objective-C iOS Development for Legacy & Enterprise Apps