With the new xcode7, Apple introduced generics and nullable for Objective-C ( Developer's Guide )
But he seems to be very different from what we have on the fast.
admissibility empty:
- (nonnull NSString *)something { return nil; }
This should trigger a warning! And you can even assign the return value of this method to a nonnull variable, for example:
//@property (copy, nonnull) NSString *name obj.name = [obj something];
Generics: In this example:
@property (nonatomic, strong, nonnull) NSMutableArray <UIView *> *someViews;
a warning appears when something other than a UIView is added to the array
[self.someViews addObject:@"foobar"];
but not in this case:
self.someViews = [@[@"foobar"] mutableCopy];
and in this case:
NSString *str = [self.someViews firstObject];
So the question is am I using generics and invalid in the wrong order or are they far from the Swift implementation?
source share