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

Xcode 4.5 warns about sending Class pointer to parameter of type id<NSCopying> #15

Open
MSch opened this issue Jun 17, 2012 · 2 comments

Comments

@MSch
Copy link

MSch commented Jun 17, 2012

Here:

static void RegisterCustomSubclass(Class subclass, Class superclass)
{
    [gCustomSubclassMap setObject: subclass forKey: superclass];
    [gCustomSubclasses addObject: subclass];
}

Can this warning be ignored?

@mikeash
Copy link
Owner

mikeash commented Jun 17, 2012

It may be worth filing a bug about this with Apple. Classes do conform to NSCopying and in fact the docs explicitly call out use as a dictionary keys as a reason for this:

https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/Reference/Reference.html#//apple_ref/occ/instm/NSObject/copy

In any case, casting it to id or id<NSCopying> should shut it up.

@steipete
Copy link

I had the same problem and spoke to some engineers at WWDC, but didn't get a clear answer. Class is a subclass from NSObject, and NSObject has a private static method called copyWithZone, so everything will work. They recommended using NSStringFromClass or, as @mikeash noted, just casing the problem away with id.

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