New __NSDictionary0 class doesn't implement required init method.

Originator:brian.nickel
Number:rdar://21795786 Date Originated:13-Jul-2015 10:44 AM
Status:Closed Resolved:31-Jul-2015 06:13 AM
Product:iOS SDK Product Version:iOS 9 beta 2 and 3, public beta
Classification:Crash Reproducible:Always
 
Summary:
I have a category on NSDictionary which creates a new dictionary of the same class using `[[self class] dictionaryWithDictionary:obj]`.  This works fine for mutable dictionaries or dictionaries containing at least one object but dictionaries of zero objects have started crashing in iOS9 saying that __NSDictionary0 doesn't implement -[initWithObjects:forKeys:count:]

Steps to Reproduce:
Run the following code or the attached project:

    id md = [NSMutableDictionary dictionary];
    id d1 = @{@"foo": @"bar"};
    id d0 = @{};
    [[md class] dictionaryWithDictionary:md]; // OK
    [[d1 class] dictionaryWithDictionary:d1]; // OK
    [[d0 class] dictionaryWithDictionary:d0]; // Crash

Expected Results:
The third method call should return a new immutable dictionary, basically:

- initWithObjects:objs forKeys:keys count:count
{
    return [[NSDictionary alloc] initWithObjects:objs forKeys:keys count:count];
}

Actual Results:
App crashes.

Version:
iOS 9 beta 2 and 3, public beta

Notes:


Configuration:
iOS simulator, all devices

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!