NSStringとFoundation型の操作
Objective-Cの主要なFoundationクラスであるNSString、NSArray、NSDictionaryを使いこなし、レガシーiOSアプリでテキストやコレクションを扱います。
「NSStringとFoundation型の操作」はCoddyKit上の無料Objective-C iOS Development for Legacy & Enterprise Appsレッスンです。 これはレッスン4/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはObjective-C iOS Development for Legacy & Enterprise Apps学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Objective-C iOS Development for Legacy & Enterprise Appsコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
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.
よくある質問
「NSStringとFoundation型の操作」レッスンは無料ですか?
はい。「NSStringとFoundation型の操作」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Objective-C iOS Development for Legacy & Enterprise Appsコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Objective-C iOS Development for Legacy & Enterprise Appsコースには全4レッスンが含まれています。
「NSStringとFoundation型の操作」で何を学びますか?
Objective-Cの主要なFoundationクラスであるNSString、NSArray、NSDictionaryを使いこなし、レガシーiOSアプリでテキストやコレクションを扱います。 ブラウザで直接実行するハンズオンコードでObjective-C iOS Development for Legacy & Enterprise Appsを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
Objective-C iOS Development for Legacy & Enterprise Appsを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのObjective-C iOS Development for Legacy & Enterprise Appsは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン4/4です。
「NSStringとFoundation型の操作」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このObjective-C iOS Development for Legacy & Enterprise Appsレッスンでコードを書いて実行できますか?
はい。すべてのObjective-C iOS Development for Legacy & Enterprise Appsレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- Objective-C入門
- 基本構文とデータ型
- Objective-C向けXcodeのセットアップ
- NSStringとFoundation型の操作