id
This type is defined as a pointer to an object.-in reality, a ponter to the instance variables of the object, the object's unique data.
id
& instancetype
Docs - id
& instancetype
-> instancetype
은 class의 명확한 type을 returen하는 반면, id는 꽤 모호한 타입임.
Selector
A selector is the name used to select a method to execute for an object, or the unique identifier that replaces the name when the source code compiled.
A selector by itself doesn't do anything. It simply identifies a method.
The only thin that makes the slector method name differenct from a plain string is that the compiler makes sure that selectors are unique.
What makes a selector useful is that (in conjuction with the runtime) it acts like a dynamic func pointer that, for a given name, automatically points to the implementation of a method appropriate for whichever class it's used with
Docs - Selector
SEL aSelector = @selector(methodName);
SEL aSelector = NSSelctorFromString(@"methodName");
SEL aSelector = @selector(run);
[aDog performSelector: aSelector];
[anAthlete performSelector: aSelector];
[aComputerSimulation performSelector: aSelector];
나는 Selector를 함수의 변수타입으로 이해했다.
NS_ASSUME_NONNULL_BEGIN
& NS_ASSUME_NONNULL_END
To ease adoption of the new annotations, you can mark certain regions of your ObC header files as audited for nullability.
Within these regions, any simple pointer type will be assumed to be nonnull.
~_BEGIN
으로 선언으로 구간시작해서_END
선언 해서 구간 닫음.
NONNULL이라 가정해야할 곳은 사용하는 부분이라고 생각하는데.. 이건 내가 ObjectiveC를 아직 잘 몰라서 의문이 생긴거 같다.
그래서 검색해봄
대답 :
참고) Nullability and Objective-C
요지 : .h에서 method선언 할 때 parameter non-null이어야하면 nonnull
적어줘야하는데, NS_ASSUME_NONNULL_BEGIN
& NS_ASSUME_NONNULL_END
로 범위 설정한 내부에서는 nonnull
붙이지 않아도 non-null이라고 가정함!