Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot initialize a parameter of type 'id<NSCopying> _Nonnull' with an rvalue of type 'Class' #28

Open
FycGitHub opened this issue Oct 23, 2020 · 2 comments

Comments

@FycGitHub
Copy link

111

NSArray> *FBGetObjectStrongReferences(id obj, NSMutableDictionary> *> *layoutCache) { NSMutableArray> *array = [NSMutableArray new];

__unsafe_unretained Class previousClass = nil;
__unsafe_unretained Class currentClass = object_getClass(obj);

while (previousClass != currentClass) {
NSArray<id> *ivars;

if (layoutCache && currentClass) {
  ivars = layoutCache[currentClass];
}

if (!ivars) {
  ivars = FBGetStrongReferencesForClass(currentClass);
  if (layoutCache && currentClass) {
    layoutCache[currentClass] = ivars;
  }
}
[array addObjectsFromArray:ivars];

previousClass = currentClass;
currentClass = class_getSuperclass(currentClass);

}

return [array copy];
}

问题总结:
layoutCache[currentClass] = ivars; 这行代码报的错,注释掉就能正常编译

@lexuanquynh
Copy link

how to fix it? if you comment this line code. Did it generate an error?

@CaiChenghan
Copy link

CaiChenghan commented Apr 27, 2021

可以这么改:

layoutCache[(id<NSCopying>)currentClass] = ivars;

facebook/FBRetainCycleDetector#115

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants