该UIKeyboardAnimationCurveUserInfoKey
有一个UIViewAnimationCurve
值.如何将其转换为相应的UIViewAnimationOptions
值以用于options
参数+[UIView animateWithDuration:delay:options:animations:completion:]
?
// UIView.h
typedef enum {
UIViewAnimationCurveEaseInOut, // slow at beginning and end
UIViewAnimationCurveEaseIn, // slow at beginning
UIViewAnimationCurveEaseOut, // slow at end
UIViewAnimationCurveLinear
} UIViewAnimationCurve;
// ...
enum {
// ...
UIViewAnimationOptionCurveEaseInOut = 0 << 16, // default
UIViewAnimationOptionCurveEaseIn = 1 << 16,
UIViewAnimationOptionCurveEaseOut = 2 << 16,
UIViewAnimationOptionCurveLinear = 3 << 16,
// ...
};
typedef NSUInteger UIViewAnimationOptions;
Run Code Online (Sandbox Code Playgroud)
显然,我可以使用switch
语句创建一个简单的类别方法,如下所示:
// UIView+AnimationOptionsWithCurve.h
@interface UIView (AnimationOptionsWithCurve)
@end …
Run Code Online (Sandbox Code Playgroud) 在Sinatra,是否可以content_type 'application/json'
设置默认值?因为我正在写一个api.
使用alloc
或autorelease
初始化器更好(更快,更高效).例如:
- (NSString *)hello:(NSString *)name {
return [[NSString alloc] initWithFormat:@"Hello, %@", name];
}
Run Code Online (Sandbox Code Playgroud)
要么
- (NSString *)hello:(NSString *)name {
return [NSString stringWithFormat:@"Hello, %@", name];
// return [@"Hello, " stringByAppendingString:name]; // even simpler
}
Run Code Online (Sandbox Code Playgroud)
我知道在大多数情况下,这里的表现无关紧要.但是,我仍然希望养成以更好的方式做这件事的习惯.
如果他们做同样的事情,那么我更喜欢后一种选择,因为它的输入更短,更具可读性.
在Xcode 4.2,有没有办法,看看有什么ARC编译成,也就是说,它把retain
,release
,autorelease
,等?切换到ARC时,此功能非常有用.我知道你不应该考虑这些东西,但它能帮助我弄清楚这些问题的答案.
cocoa cocoa-touch memory-management objective-c automatic-ref-counting
使用curl命令行工具,是否可以echo
打印或查看请求,而不是发送请求?有点像-n
选项吗?我想看到请求标题和正文,以及包含的任何其他内容.除了标题和正文之外还有其他什么吗?
有时候,尤其是 当我是唯一一个在远程存储库上工作的人时,我喜欢用git rebase -i
和重写历史git push origin master -f
.
如何在git pull origin master
没有合并的情况下强制执行?我尝试了-f
选项,但是没有用.我只想重写我本地git仓库的历史记录以匹配远程(原点)的历史记录.
我做了一个UIView
具有固定框架的子类.那么,我可以覆盖init
而不是initWithFrame:
吗?例如:
- (id)init {
if ((self = [super initWithFrame:[[UIScreen mainScreen] bounds]])) {
self.backgroundColor = [UIColor clearColor];
}
return self;
}
Run Code Online (Sandbox Code Playgroud)
Xcode文档-initWithFrame:
说:"如果以编程方式创建视图对象,则此方法是类的指定初始化程序UIView
.子类可以重写此方法以执行任何自定义初始化,但必须super
在其实现开始时调用."
"指定初始化程序"是什么意思?
在使用单元测试创建新项目时,Xcode将构建配置设置为Test for Test方案(与Run方案相同).
我应该区分Run(Command-R)和Test(Command-U)方案吗?
即,我应该创建一个名为Test的新构建配置,向它添加预处理器宏TEST = 1,并将其用作测试方案的构建配置吗?或者,我应该将Run&Test作为Debug进行保存吗?
我来自Ruby/Rails背景,您通常拥有测试,开发和生产环境.在我看来,Debug就像开发一样,Release就像生产一样,但是我们错过了一个测试,这就是我认为添加Test可能有意义的原因.
评论?意见?建议?
我特意问这个,因为我想为Test编译一些东西:
#ifdef TEST
// Do something when I test.
#endif
Run Code Online (Sandbox Code Playgroud)
如果我也为Debug编译它,我认为这不重要.所以,我真的可以做到:
#ifdef DEBUG
// Do something when I run or test.
#endif
Run Code Online (Sandbox Code Playgroud)
但是,我真的只打算在现在进行测试.所以,这就是为什么我认为我应该区分调试和测试,但我想知道为什么Xcode默认不为你做那个?Apple认为你不应该区分它们吗?
MongoDB有类似.bash_history
文件的东西吗?
我最近键入了一个长命令,关闭并重新打开shell,并想要检索它.
按下按钮不起作用,因为似乎在新shell中无法访问最后一个shell的历史记录.
我用Homebrew安装了1.8.1.我应该设置一个配置变量来打开MongoDB交互式shell历史记录吗?
这是我的mongod.conf
档案:
# Store data in /usr/local/var/mongodb instead of the default /data/db
dbpath = /usr/local/var/mongodb
# Only accept local connections
bind_ip = 127.0.0.1
# Enable Write Ahead Logging (not enabled by default in production deployments)
journal = true
Run Code Online (Sandbox Code Playgroud) 我正在运行Rails 2.3.2.
我如何转换"Cool"
为"cool"
?我知道"Cool".downcase
有效,但有没有一个Ruby/Rails方法,相反的capitalize
,即,uncapitalize
或decapitalize
?
ios ×2
objective-c ×2
ruby ×2
uiview ×2
bdd ×1
capitalize ×1
cocoa ×1
cocoa-touch ×1
content-type ×1
curl ×1
debugging ×1
echo ×1
enums ×1
git ×1
git-fetch ×1
git-pull ×1
git-push ×1
history ×1
http-headers ×1
httprequest ×1
init ×1
javascript ×1
json ×1
lowercase ×1
mongodb ×1
node.js ×1
request ×1
sinatra ×1
subclass ×1
uikit ×1
unit-testing ×1
xcode ×1