이는 클래스 구현 자체 외부에서 사용되지 않는 메소드를 선언하는 데 매우 합법적 인 방법입니다.
컴파일러는 사용 된 메소드보다 선행하는 한 구현 파일에서 메소드를 찾습니다. 그러나 새로운 LLVM 컴파일러는 메소드가 임의의 순서로 선언되고 주어진 파일에서 참조 될 수 있기 때문에 항상 그런 것은 아닙니다. 당신이 downvote 너무 친절하시기 바랍니다
//In the Header File, MyClass.h
@interface MyClass : NSObject
@end
//in the implementation file, MyClass.m
//Method Decls inside a Private Category
@interface MyClass (_Private)
- (void)doSomething;
@end
//As a class extension (new to LLVM compiler)
@interface MyClass()
- (void)doSomething;
@end
@implementation MyClass
//You can also simply implement a method with no formal "forward" declaration
//in this case you must declare the method before you use it, unless you're using the
//latest LLVM Compiler (See the WWDC Session on Modern Objective C)
- (void)doSomething {
}
- (void)foo {
[self doSomething];
}
@end
는 이유를 추가 :
는 구현 파일 내부의 방법을 선언하는 다른 스타일의 몇 가지가 있습니다. – Pfitz