As suggested in the answer to
How to get classname in objective c Like 'NSString', you could use classForCoder
instead of class
. Example:
NSArray *a = @[@"foo"];
NSMutableArray *b = [a mutableCopy];
NSLog(@"a class: %@", [a class]); // -> __NSArrayI
NSLog(@"b class: %@", [b class]); // -> __NSArrayM
NSLog(@"a classForCoder: %@", [a classForCoder]); // -> NSArray
NSLog(@"b classForCoder: %@", [b classForCoder]); // -> NSMutableArray
So this test should give the expected results:
- (void)testReturnedObjectIsOfTypeImmutableArray
{
XCTAssertEqualObjects([NSArray class],
[[NSArray reverseArray:self.array] classForCoder],
@"NSArray should be returned");
}