So, obviously, after WWDC I'm playing with new stuff presented during last week. As you know Apple introduced generics to the world of Objective-C
Note: This answer is somehow follow-up to this question: Are there strongly-typed collections in Objective-C?
I tried this code in method, works great
NSMutableArray<NSString*> *array = [[NSMutableArray alloc] init];
[array addObject:@""];
[array addObject:@(54)];Incompatible pointer types sending 'NSNumber *' to parameter of type 'NSString * __nonnull'
// Great, generics works as expected.
However I also have method I want to transform to generics
In header file:
- (NSArray <NSString*> *)objectsToSearch;
Implementation:
- (NSArray <NSString*> *)objectsToSearch
{
NSString *first = @"1";
NSString *second = @"2";
NSString *third = @"3";
NSNumber *test = @(55);
return @[first, second, third, test]; // No-error!!!
}
Am I doing something wrong or Clang does not support generics + literals or there is something else I'm missing?