ビデオ: 【プログラミング】swiftでHelloと表示してみよう【iPhoneアプリ開発・初心者】 #6 2025
明らかに、iOSアプリケーション用のクラスの実装はメソッドの実装で構成されています。以下のリストは、メソッドの実装がどのようなものか、そしてクラスの全体的な実装仕様がどのように見えるかについての良い考えを示しています。次のように、@implementationディレクティブで囲まれた実装仕様を使用して、クラスを実装します。
@implementation; …… -d
これはStackOfIntegerクラスの実装です:
<! - 1 - >@implementation StackOfInteger; - (id)init {self = [スーパーinit];最後= -1;要素= [[NSMutableArray alloc] init]; (int)intValue {NSNumber * intObject = [NSNumber numberWithInt:intValue];}戻り値の型を取得するには、次のように入力します。 [要素addObject:intObject];最後の++;} - (void)push2:(int)intValue1 another:(int)intValue2 {NSNumber * intObject = [NSNumber numberWithInt:intValue1]; [要素addObject:intObject]; intObject = [NSNumber numberWithInt:intValue2]; [要素addObject:intObject]; last = 2;} - (int)pop {NSNumber * element =(NSNumber *)[要素objectAtIndex:last];最終 -; int intValue = [要素のint値]; [要素removeLastObject]; return intValue;} -d
