이상한 개인api 호출 오류
CALayer
사유apidoubleBounds
가 있는데 이 사유api가 되돌아오는 데이터를 방문하려면 다음 코드를 사용한다.id valuedoubleBounds = [view.layer performSelector:NSSelectorFromString(@"doubleBounds")];
결과 붕괴 발견, 알림
-[CALayer doubleBounds]: unrecognized selector sent to instance
링크에 따라: CALayer.h3 알 수 있다doubleBounds
는 아래에 정의된 구조체 데이터를 되돌려주고 역사 기록을 보면 iOS7에서 iOS10까지 이 방법이 계속 존재한다는 것을 알 수 있다CALayer
(struct CADoubleRect {
struct CADoublePoint {
double x_1_1_1; double x_1_1_2;
} x1;
struct CADoubleSize { double x_2_1_1; double x_2_1_2;
} x2;
})doubleBounds;
저는 비탈옥 환경에서 이 개인api를 호출했습니다. 현재 iOS 10. 테스트를 하고 있습니다.3.3과 iOS7 탈옥 장치가 이api를 호출하면 붕괴됩니다. 이 개인api를 호출하는 것은 필요하지 않지만 왜 이 개인api를 호출하면 오류가 발생하는지 알고 싶습니다.
같은 환경에서
UIView
의 사유apirecursiveDescription
를 호출하면 전혀 문제가 없다역방향 게시판에 질문을 했는데 답이 쏟아졌어요. MapKit에 있을 줄은 꿈에도 몰랐어요. 제가 역방향 UIScrollView에 있는 어떤 방법에서 이 방법을 봤기 때문이에요. "image list"명령은 정말 좋은 거예요. 아까 제가 오래된 프로젝트에서 호출
id valuedoubleBounds = [self.view.layer performSelector:NSSelectorFromString(@"doubleBounds")];
한 건에 문제가 있다는 걸 알았는데 CALayer
대상으로 돌아왔어요. 이것도 믿을 수가 없어요.마지막으로 다음 코드를 통해 실제 값을 얻을 수 있습니다.SEL selector = NSSelectorFromString(@"doubleBounds");
IMP imp = [self.view.layer methodForSelector:selector];
CGRect (*func)(id, SEL) = (void*)imp;
CGRect doubleBounds = func(self.view.layer, selector);
NSLog(@"doubleBounds is %@", NSStringFromCGRect(doubleBounds));
오래된 프로젝트의 코드를 검색해 보니 과연 한 곳에 #import "MapKit/MapKit.h"라고 쓰여 있었다. 그러나SDWebImage에서 프로젝트 설정에 MapKit.가 추가된 것을 보지 못했다.프레임워크, 새로 만든 프로젝트는 이 프레임워크를 추가해야 붕괴되지 않습니다. 전자는 어느 제3자 프레임워크가 자체로MapKit를 추가한 것으로 추정됩니다.framework
하지만 dladdr로 위치를 정하는 대신의 힌트도 있습니다. 대신은 대신입니다. 키워드가 있으면 됩니다. 새로운 스킬Get:
#import
#include
#include
Dl_info info;
if (dladdr(imp, &info)) {
printf("dli_fname: %s
", info.dli_fname);
printf("dli_sname: %s
", info.dli_sname);
printf("dli_fbase: %p
", info.dli_fbase);
printf("dli_saddr: %p
", info.dli_saddr);
} else {
printf("error: can't find that symbol.
");
}
결과:
dli_fname: /System/Library/Frameworks/MapKit.framework/MapKit
dli_sname:
dli_fbase: 0x194256000
dli_saddr: 0x1943c7c0c
만약
self.view.layer
를 사용한 후에 단점을 더하면console에서 두드리기:po [CALayer _shortMethodDescription]
인쇄된 함수 목록에 표시doubleBounds
가 있습니다. 모든 종류 방법, 속성, 실례 방법을 인쇄합니다.- (void) setDoublePosition:(struct CGPoint)arg1; (0x1943c7c00)
- (struct CGRect) doubleBounds; (0x1943c7c0c)
다음과 같은 조회를 사용할 수도 있습니다.
(IMP) imp = 0x00000001943c7c0c (MapKit`-[CALayer(MKDoubleLayer) doubleBounds])
(lldb) image lookup -a 0x00000001943c7c0c
Address: MapKit[0x000000018de53c0c] (MapKit.__TEXT.__text + 1505440)
Summary: MapKit`-[CALayer(MKDoubleLayer) doubleBounds]
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.