#import <UIKit/UIKit.h>
@protocol IAppResult <NSObject>
@optional
-(void)onReceiveAppResult:(NSString *)id and:(NSString *)password;
@end
@interface AppTask : NSObject
+(void)authApp:(NSString *)url listener:(id<IAppResult>)listener;
@end
- + 함수에 대해서
- : instatnce 메소드
+ (void)classMethod;
클래스에 메시지를 보내려면 다음 메시지 표현식에 클래스 이름을 수신기로 입력하십시오.
[MyClass Method];
클래스 메소드. 클래스 메서드는 클래스의 인스턴스(instance)가 아닌 클래스 개체에서 작동하는 방법이다. 목표-C에서 클래스 방법은 방법 선언 및 실행의 시작 부분에서 더하기(+) 기호로 표시된다.
(+) Class methods:-
Are methods which are declared as static. The method can be called without creating an instance of the class. Class methods can only operate on class members and not on instance members as class methods are unaware of instance members. Instance methods of the class can also not be called from within a class method unless they are being called on an instance of that class.
정적(static)으로 선언된 방법이다. 이 방법은 클래스의 인스턴스를 만들지 않고도 호출할 수 있다. 클래스 방법은 인스턴스 멤버를 알지 못하기 때문에 인스턴스 멤버에 대해서만 작동할 수 없고 인스턴스 멤버에 대해서도 작동할 수 없다. 클래스의 인스턴스 메서드는 해당 클래스의 인스턴스에서 호출되지 않는 한 클래스 메서드 내에서 호출할 수 없다.
(-) Instance methods:-
On the other hand require an instance of the class to exist before they can be called, so an instance of a class needs to be created by using the new keyword. Instance methods operate on specific instances of classes. Instance methods are not declared as static.
반면 클래스의 인스턴스가 호출되기 전에 존재해야 하므로 새로운 키워드를 사용하여 클래스의 인스턴스를 만들어야 한다. 인스턴스(instance) 방법은 클래스의 특정 인스턴스에서 작동한다. 인스턴스(instance) 방법은 정적인 것으로 선언되지 않는다.
How to create?
@interface CustomClass : NSObject
+ (void)classMethod;
- (void)instanceMethod;
@end
How to use?
[CustomClass classMethod];
CustomClass *classObject = [[CustomClass alloc] init];
[classObject instanceMethod];
참고
'iOS' 카테고리의 다른 글
WKWebView 대응 (2) | 2020.12.03 |
---|---|
IOS 푸시 서비스 (1) | 2020.11.20 |
애플님의 강경 정책 (0) | 2020.04.29 |
꼼꼼한 재은씨의 Swift 실전편 (0) | 2020.02.22 |
네이버 동영상 중급강의 3 (0) | 2020.02.22 |
댓글