由alloc、copy、new、mutableCopy修饰的对象都会使引用计数值加一 release:释放对象 release = 0时,废弃对象 (1)带有alloc/new/copy/mutableCopy关键字,是自己生成对象并持有,自己持有的对象,自己得释放(release) (2)取得任何 ...
分类:
其他好文 时间:
2017-11-24 15:12:55
阅读次数:
146
方法 1: 声明 :+ (instancetype)sharedInstance 单例方法 重写:+ (instancetype)allocWithZone:(struct _NSZone *)zone (+(instancetype)alloc 和 +(instancetype)new 都会走 a ...
分类:
其他好文 时间:
2017-11-24 14:53:01
阅读次数:
352
c++primer 中的一个函数报错的问题 StrVec类的设计中定义这个类,定义了一个static变量alloc,用来分配内存和构造元素 class StrVec{public: StrVec() :elements(nullptr), first_free(nullptr), cap(nullp ...
分类:
编程语言 时间:
2017-11-14 22:21:42
阅读次数:
424
OC采用ARC机制,因此strong等属性也有了应用场景。当使用alloc为一个对象在堆中分配内存空间,然后让栈区使用一个强指针指向该内存地址,就能在指针被自动释放签前,保证堆内数据不被释放。那么如果不是用强指针,而是用弱指针执行该堆内存地址,那么在分配内存空间后就会自动释放。 那么,针对这种运用场 ...
分类:
移动开发 时间:
2017-11-13 19:52:24
阅读次数:
158
1 /** 2 * alloc_chrdev_region() - register a range of char device numbers 3 * @dev: output parameter for first assigned number 4 * @baseminor: first o... ...
分类:
其他好文 时间:
2017-11-11 19:01:29
阅读次数:
169
//获取当前系统时间的时间戳 #pragma mark - 获取当前时间的 时间戳 +(NSInteger)getNowTimestamp{ NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setDate ...
分类:
移动开发 时间:
2017-11-08 11:58:25
阅读次数:
235
1、先po代码 // 退出程序 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 UIAlertView* alert = [[UIAlertView alloc] initWi ...
分类:
移动开发 时间:
2017-11-07 19:54:39
阅读次数:
318
UILabel *Label = [[UILabel alloc]init]; Label.text = @"长一点也是可以的"; Label.textColor = black_Color; Label.textAlignment = NSTextAlignmentLeft; gsmcLabel. ...
分类:
其他好文 时间:
2017-11-03 13:11:24
阅读次数:
159
CGPoint itemSprite1position = ccp(100,200); NSMutableArray * array = [[NSMutableArray alloc] initWithObjects:NSStringFromCGPoint(itemSprite1position), ...
分类:
移动开发 时间:
2017-10-29 14:38:48
阅读次数:
221
// 播放音乐 NSString *path = [[NSBundle mainBundle] pathForResource:@"1670" ofType:@"mp3"]; NSError * error; self.avaPlayer= [[AVAudioPlayer alloc] initWi ...
分类:
移动开发 时间:
2017-10-17 12:21:05
阅读次数:
183