Skip to content

Instantly share code, notes, and snippets.

@yuxiangq
Last active April 18, 2016 16:18
Show Gist options
  • Save yuxiangq/60e1e8d8d8c32734e5b2aa31d2166873 to your computer and use it in GitHub Desktop.
Save yuxiangq/60e1e8d8d8c32734e5b2aa31d2166873 to your computer and use it in GitHub Desktop.
iOS中的泛型
#import "ViewController.h"
@interface ViewController ()
@property (strong, nonatomic) NSMutableArray<NSNumber*> *numbersArray;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.numbersArray = [NSMutableArray new];
NSObject *o = [NSObject new];
[self.numbersArray addObject:o];//产生警告,incompatible pointer types sending 'NSObject*' to parameter of type 'NSNumber* _Nonnull'
[self.numbersArray addObject:@(1)];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment