Get the App
SLTechnology News&Howtos  ›  Development  › 

Classification in Objective-C

Shulou Source: shulou.com Published: 2022-06-02 10:57:53 10月25日 Update

This article shows you the categories in Objective-C, which are concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

Animal.h

# import

@ interface Animal: NSObject

-(void) eat: (NSString *) food

@ end

Animal.m

# import "Animal.h"

@ implementation Animal

/ * *

Eat

/

-(void) eat: (NSString) food {

NSLog (@ "I like eat% @", food)

}

@ end

Testing in the main entry

# import

# import "Animal.h"

Int main (int argc, const char argv []) {

@ autoreleasepool {

Animal dog = [[Animal alloc] init]

NSString * food = @ "Bone"

[dog eat:food]

}

Return 0

}

Results:

First, name and classify AnimalPart

H:

# import

# import "Animal.h"

@ interface Animal (AnimalPart)

-(void) call: (NSString *) sound;@end

Tags: Categories documents results realistic content skills knowledge testing concise concise code entry that is properties articles methods more articles industries information Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Shulou Technology Shulou Information Apple NVidia