是否有适用于XCode项目的良好单元测试和验收测试框架?我习惯于在Ruby和Python中使用TDD,但它是Objective-C和XCode的新手.
我有一个管理借方和贷方的发票系统.基本上,发票金额是通过其借方总和获得的,余额是通过获取其贷方总额并将其减去总金额得出的.
我正在用四种型号做这件事.
它的工作方式是通过一个连接模型(行项),它具有一个名为recordable的多态关联.乍一看似乎一切正常.但是,检查订单项会显示,当recordable_id显示正常时,recordable_type为nil.
这是代码的细分:
class Invoice < ActiveRecord::Base
has_many :line_items, :dependent => :destroy
has_many :debits, :through => :line_items, :as => :recordable
has_many :credits, :through => :line_items, :as => :recordable
end
class LineItem < ActiveRecord::Base
belongs_to :invoice
belongs_to :recordable, :polymorphic => true
belongs_to :credit, :class_name => "Credit", :foreign_key => "recordable_id"
belongs_to :debit, :class_name => "Debit", :foreign_key => "recordable_id"
end
class Credit < ActiveRecord::Base
has_many :line_items, :as => :recordable, :dependent => :destroy
end
class Debit < ActiveRecord::Base …Run Code Online (Sandbox Code Playgroud) ruby ruby-on-rails has-many-through polymorphic-associations
我正在尝试通过对 Google 健身历史 API 的单个请求来获取过去两周的每日步数总计。但数据并没有根据用户自己的时区按天对数据进行分桶。至少——这是我的假设。以下是我得到的输出与 google fit 应用程序中报告的步数总数的比较:
Field (steps) Key (2015-08-05) Value(5028) | FitApp(4448)
Field (steps) Key (2015-08-06) Value(5158) | FitApp(2973)
Field (steps) Key (2015-08-07) Value(5828) | FitApp(7862)
Field (steps) Key (2015-08-08) Value(5300) | FitApp(4413)
Field (steps) Key (2015-08-10) Value(1071) | FitApp(2741)
Field (steps) Key (2015-08-10) Value(2715) | (duplicate day returned)
Run Code Online (Sandbox Code Playgroud)
这是我提出请求的方式:
// Setting a start and end date using a range of 2 weeks before this moment.
Calendar cal = Calendar.getInstance();
Date now = new Date();
cal.setTime(now);
long …Run Code Online (Sandbox Code Playgroud) 我正在运行一个简单的函数,可以在多个区域调用,以帮助在方向更改期间处理iPad应用程序上的布局.它看起来像这样:
- (void) getWidthAndHeightForOrientation:(UIInterfaceOrientation)orientation {
NSLog(@"New Orientation: %d",orientation);
end
Run Code Online (Sandbox Code Playgroud)
我在各种各样的地方称它为:
[self getWidthAndHeightForOrientation: [[UIDevice currentDevice] orientation]];
Run Code Online (Sandbox Code Playgroud)
该函数通常有一些简单的代码,如果方向是纵向或横向,则运行.不幸的是,当应用程序以位置1开始时,它没有按预期工作.结果我得到0.稍后如果以相同的方式调用该函数但该设备从未被旋转,则返回值5.这是什么意思?为什么会抛出这些值?
简而言之,为什么[[UIDevice currentDevice] orientation]会抛出0或5而不是1到4之间的任何值?
更新:
因为处理方向的方式我在代码中不断发现错误,所以我写了一篇关于如何处理UIDevice或UIInterface方向的权威帖子:http://www.donttrustthisguy.com/orientating-yourself-in-ios
我正在尝试以编程方式tintColor为UIBarButtonItems整个项目设置for .我打电话给:
[UIBarButtonItem appearance]
但是,在查看Apple的文档之后:http: //developer.apple.com/library/ios/#documentation/uikit/reference/UIBarButtonItem_Class/Reference/Reference.html
我发现没有这样的属性来设置tintColor.我能找到的最接近的相关方法是:
setBackgroundImage:forState:barMetrics:
setBackgroundImage:forState:style:barMetrics:
Run Code Online (Sandbox Code Playgroud)
但是,这两种方法都用于设置实际的背景图像.是不是可以简单地设置按钮的tintColor通过UIAppearance?
我的客户希望使用301重定向来强制其网站上的"www"子域.所以'example.com/something'解析为'www.example.com/somthing'等.
我想要做的只是将其添加到我的vhost文件中:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName example.com
ServerAlias www.*
DocumentRoot /data/apps/example.com/current/public
RailsBaseURI /
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule ^ http://www.example.com%{REQUEST_URI} [L,R=301]
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
我还确保通过以下方式启用了mod重写:
sudo a2enmod rewrite
sudo /etc/init.d/apache2 force-reload
Run Code Online (Sandbox Code Playgroud)
我目前努力的结果似乎基本上是成功的.Apache重新启动,一切都按预期工作除了重写没有发生.所以'www.example.com'和'example.com'都解决了.浏览器不会被重定向到"www.example.com".有任何想法吗?我已经尝试重新加载配置并重启apache几次,但我似乎无法让重写规则正常工作.我是通过将它们放在vhost中而不是.htaccess文件中将它们设置在错误的位置吗?
这里的任何建议都会有用.我完全不知所措.
objective-c ×3
android ×1
apache2 ×1
date ×1
google-fit ×1
ios ×1
ipad ×1
iphone ×1
java ×1
mod-rewrite ×1
orientation ×1
passenger ×1
ruby ×1
tdd ×1
uiappearance ×1
unit-testing ×1
vhosts ×1
xcode ×1