Jack 10 J 10 A 20 Lu cal 20 A bc U 20
我想得到这些数字的总和:10 + 10 + 20 + 20 + 20 = 80
但是我不能cat input|cut -d " " -f 3用来获取数字,我怎么能这样做?
如果我需要更新视图的框架,我可以将该代码放入-(void)viewWillLayoutSubviews如下:
- (void)viewWillLayoutSubviews {
self.demoView.frame = CGRectMake(0, 0, 10, 10);
}
Run Code Online (Sandbox Code Playgroud)
或者在视图的方法中- (void)layoutSubviews.
但是,如果我现在使用autolayout,并且我需要NSLayoutConstraint在代码中更新对象动态,我不知道将代码放在哪里self.demoWidthConstraint = 10
我的应用程序通过两种方式阅读所有联系人:
for循环:
CFAbsoluteTime startTime = CFAbsoluteTimeGetCurrent ();
long count = macContact.addressBook.people.count;
for(int i=0;i<count;++i){
ABPerson *person = [macContact.addressBook.people objectAtIndex:i];
NSLog(@"%@",person);
}
NSLog(@"%f",CFAbsoluteTimeGetCurrent() - startTime);
Run Code Online (Sandbox Code Playgroud)
的for-each
CFAbsoluteTime startTime = CFAbsoluteTimeGetCurrent ();
for(ABPerson *person in macContact.addressBook.people){
NSLog(@"%@",person);
}
NSLog(@"%f",CFAbsoluteTimeGetCurrent() - startTime);
Run Code Online (Sandbox Code Playgroud)
for-each只花了4秒钟在地址簿中列举5000人,而for循环用了10分钟来完成同样的工作.
我想知道为什么性能会有很大差异?
我用以下代码创建了一个UILabel:
UILabel *textLabel = [[UILabel alloc] initWithFrame:CGRectZero];
textLabel.font = [UIFont systemFontOfSize:30];
textLabel.backgroundColor = [UIColor redColor];
textLabel.text = @"0";
[textLabel sizeToFit];
textLabel.center = CGPointMake(100, 100);
[self.view addSubview:textLabel];
Run Code Online (Sandbox Code Playgroud)
textLabel.bounds.height似乎高于文本字体的实际高度.如下:

但是因为设计师根据实际文本大小标记了两个UILabel的空间,所以我不能只为两个UILabel使用设计器的标记空间分配一个值,我需要在模拟器中运行app来检查它是否正确.
我想知道如何使UILabel sizeTofit获得文本的真实高度,文本之间没有填充.
select * from workers where id = uid and age = uage` -- sql1
select uid,uage from users where uage>20` -- sql2
Run Code Online (Sandbox Code Playgroud)
我想使用sql2的条件sql1,即在uid与uage中使用sql1是从何而来sql2.
我没有使用标准工具栏,而是想实现类似工具栏的Finder,使用按钮如下:

但我的实施看起来很奇怪.

我喜欢用"*"来搜索vim中的文本.高亮点亮目标文本后,我想编辑所有这些文件,有什么方法可以在vim中完成吗?例如,在高亮文本之后,我只需要按ctrl + i然后可以同时编辑高亮文本
有一个按钮方法:
-(void) buttonTapped:(id) sender{
dispatch_async(dispatch_queue_create("countQueue", NULL), ^{
sleep(10);
NSLog(@"%d",self.count++);
});
}
Run Code Online (Sandbox Code Playgroud)
self.count是属性:
@property (nonatomic, assign) int count;
Run Code Online (Sandbox Code Playgroud)
我想通过点击按钮多次创建"countQueue",
计算2 ^ 32的最简单方法是2*2*2*2*2......= 4294967296
,我想知道有没有其他方法可以获得4294967296?(2^16 * 2^16被视为同样的方法2*2*2....)
以及计算它的方法有多少?
有没有计算它的功能?
如果没有,我无法想出任何计算方法 2*2*2...