我只是想知道并且在将config.cache_classes设置为true时没有找到模型类(ActiveRecord)中缓存的内容的明确响应?
有人可以告诉我或指出我没找到的文件吗?
谢谢
我有一个在C#中生成MD5哈希的函数,如下所示:
MD5 md5 = new MD5CryptoServiceProvider();
byte[] result = md5.ComputeHash(data);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < result.Length; i++)
{
sb.Append(result[i].ToString("X2"));
}
return sb.ToString();
Run Code Online (Sandbox Code Playgroud)
在java中,我的函数如下所示:
MessageDigest m = MessageDigest.getInstance("MD5");
m.update(bytes,0,bytes.length);
String hashcode = new BigInteger(1,m.digest()).toString(16);
return hashcode;
Run Code Online (Sandbox Code Playgroud)
当C#代码生成:"02945C9171FBFEF0296D22B0607D522D"时,java代码生成:"5a700e63fa29a8eae77ebe0443d59239".
有没有办法为同一个bytearray生成相同的md5哈希?
一经请求:
这是java中的testcode:
File file = new File(System.getProperty("user.dir") + "/HashCodeTest.flv");
byte[] bytes = null;
try {
bytes = FileUtils.getBytesFromFile(file);
} catch (IOException e) {
fail();
}
try {
generatedHashCode = HashCode.generate(bytes);
} catch (NoSuchAlgorithmException e) {
fail(); …Run Code Online (Sandbox Code Playgroud) 我创建了一个UIButton的子类:
//
// DetailButton.h
#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
@interface MyDetailButton : UIButton {
NSObject *annotation;
}
@property (nonatomic, retain) NSObject *annotation;
@end
//
// DetailButton.m
//
#import "MyDetailButton.h"
@implementation MyDetailButton
@synthesize annotation;
@end
Run Code Online (Sandbox Code Playgroud)
我想我可以通过执行以下操作创建此对象并设置注释对象:
MyDetailButton* rightButton = [MyDetailButton buttonWithType:UIButtonTypeDetailDisclosure];
rightButton.annotation = localAnnotation;
Run Code Online (Sandbox Code Playgroud)
localAnnotation是一个NSObject,但它实际上是一个MKAnnotation.我不明白为什么这不起作用,但在运行时我得到这个错误:
2010-05-27 10:37:29.214 DonorMapProto1[5241:207] *** -[UIButton annotation]: unrecognized selector sent to instance 0x445a190
2010-05-27 10:37:29.215 DonorMapProto1[5241:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UIButton annotation]: unrecognized selector sent to instance 0x445a190'
Run Code Online (Sandbox Code Playgroud)
"
我不明白为什么它甚至会查看UIButton,因为我已经将其子类化了,所以应该查看MyDetailButton类来设置该注释属性.我错过了一些非常明显的东西.感觉就像:)
提前感谢您提供的任何帮助
罗斯
我正在设计一个应用程序,这是一个更大的工作的一部分,取决于其他人构建一个应用程序可以用来检索数据的API.
当我在考虑如何设置这个项目并围绕它设计架构时,我发生了一些事情,我相信很多人都处于类似情况.
由于我的工作取决于其他人完成他们的任务和测试服务器,这会减慢我的工作量.
所以问题是:创建测试存储库和类,实现它们的最佳实践是什么,而不必依赖于更改代码中的几个位置以在测试类和实际存储库/正确的api调用之间进行交换.
考虑以下场景:
GetDataFromApiCommand *getDataCommand = [[GetDataFromApiCommand alloc]init];
getDataCommand.delegate = self;
[getDataCommand getData];
Run Code Online (Sandbox Code Playgroud)
一旦数据通过API可用,"GetDataFromApiCommand"就可以使用实际的API,但在此之前,在调用[getDataCommand getData]时可以返回一组模拟数据.
在代码的不同位置可能存在多个这样的实例,因此无论它们在哪里都替换它们,这是一个缓慢而痛苦的过程,这不可避免地导致一两个被忽略.
在强类型语言中,我们可以使用依赖注入,只需改变一个地方.在objective-c中可以实现工厂模式,但这是最好的途径吗?
GetDataFromApiCommand *getDataCommand = [GetDataFromApiCommandFactory buildGetDataFromApiCommand];
getDataCommand.delegate = self;
[getDataCommand getData];
Run Code Online (Sandbox Code Playgroud)
达到此结果的最佳做法是什么?
由于这将是最有用的,即使您有实际的API可用,运行测试或脱机工作,ApiCommands也不一定必须永久替换,而是选择"我是否要使用TestApiCommand或ApiCommand".
更有意思的是可以选择切换:所有命令都是test,所有命令都使用实时API,而不是逐个选择它们,但这对于测试一个或两个实际API命令,混合也很有用他们有测试数据.
编辑 我选择的方式是使用工厂模式.
我按如下方式设置工厂:
@implementation ApiCommandFactory
+ (ApiCommand *)newApiCommand
{
// return [[ApiCommand alloc]init];
return [[ApiCommandMock alloc]init];
}
@end
Run Code Online (Sandbox Code Playgroud)
在任何我想使用ApiCommand类的地方:
GetDataFromApiCommand *getDataCommand = [ApiCommandFactory newApiCommand];
Run Code Online (Sandbox Code Playgroud)
当需要实际的API调用时,可以删除注释并注释掉mock.
在消息名称中使用new表示谁曾使用工厂获取对象,负责释放它(因为我们想避免在iPhone上自动释放).
如果需要其他参数,工厂需要考虑这些因素,即:
[ApiCommandFactory newSecondApiCommand:@"param1"];
Run Code Online (Sandbox Code Playgroud)
这对于存储库也很有效.
当我使用以下代码加载我的Fancybox弹出窗口时,我正在尝试向按钮标记添加按钮onclick事件:
var processOrder = function(id) {
$('#processPopupLink').fancybox({
'hideOnContentClick': false,
'frameWidth': 850,
'frameHeight': 695
}).click();
$('#processComplete').click(function() {
alert('debug');
});
}
Run Code Online (Sandbox Code Playgroud)
但是,当我点击按钮时它没有显示消息框,我不知道为什么它不起作用,任何帮助将不胜感激.
编辑
我不想让它点击按钮,我希望它能够在打开fancybox弹出窗口时为fancybox弹出窗口上的现有按钮添加onclick.
在我的iPad应用程序中,我让用户使用以下代码选择图像:
UIImagePickerController* picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.delegate = self;
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:picker];
self.popoverController = popover;
popoverController.delegate = self;
[popoverController presentPopoverFromRect:self.view.frame
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
[picker release];
Run Code Online (Sandbox Code Playgroud)
(我已经将类设置为UIPopoverControllerDelegate和UIImagePickerControllerDelegate,并且我为两个委托设置了回调.)
现在,奇怪的是,如果我从"已保存的照片"相册中选择一个图像,我的"imagePickerController:didFinishPickingImage"回调方法被调用,我得到一个图像,一切都很好.
但是,如果我从任何其他专辑中选择一个图像,我的"imagePickerControllerDidCancel"回调会被调用 - 而且我没有得到图像.
任何的想法?我在网上搜索高低......
谢谢,Reuven
情节加厚......
添加时:
allowsEditing = YES;
我仍然可以从已保存的照片相册中选择(和裁剪/缩放)图像 - 但是当尝试使用其他相册中的图像时,iPad会因调试器崩溃而显示:
2010-06-03 08:16:06.759 uPrintMobile [98412:207] *由于未捕获的异常'NSInvalidArgumentException'终止应用程序,原因:'* - [NSCFDictionary setObject:forKey:]:尝试插入nil值(键:UIImagePickerControllerOriginalImage) "
仍然没有线索......
我已经看到使用llvm的mac或linux的一些mkspec.
有没有人使用Qt的llvm编译版本?还是llvm他们的Qt项目?它加快了编译时间吗?你的项目更快吗?
我有以下VBScript:
SET Wmi = GetObject("winmgmts:\\.\root\cimv2")
SET QR = Wmi.ExecQuery("SELECT * FROM Win32_Processor")
MsgBox("" & QR.Count)
Run Code Online (Sandbox Code Playgroud)
哪个效果很好.但是,当我查询不存在的内容时:
SET Wmi = GetObject("winmgmts:\\.\root\cimv2")
SET QR = Wmi.ExecQuery("SELECT * FROM Win32_DoesNotExist")
MsgBox("" & QR.Count)
Run Code Online (Sandbox Code Playgroud)
我收到以下错误消息:
Script: E:\test.vbs
Line: 3
Char: 1
Error: Invalid class
Code: 80041010
Source: SWbemObjectSet
Run Code Online (Sandbox Code Playgroud)
我怎么知道QR对象是否有效?
如果我打电话TypeName(QR),它会说SWbemObjectSet,但是一旦我尝试查询其中一个属性,它就会失败并显示上述消息.
我已经google了这个错误,大多数页面似乎都说"只是不做那个查询"的效果.遗憾的是,这不是一个选项,因为我想在多个版本的Windows上运行相同的脚本,而Microsoft偶尔会在新版本的Windows中弃用WMI类.我希望我的脚本能够优雅地处理它.
题
任何人都可以解释(最好用代码示例)如何使用XAML以编程方式和声明方式使用AutomationProperties.Name属性?
说明
据我所知,Visual Studio 2010中的Coded UI Builder将Window的名称作为SearchProperty.
由于我的Window名称发生了变化,我希望我的Coded UI测试可以依赖一个常量的SearchProperty.
在下面的代码示例中,我不希望窗口标题被硬编码为"管道1的属性",因为它会发生变化.
代码示例
[GeneratedCode("Coded UITest Builder", "10.0.30319.1")]
public class UIListViewPropertiesTable1 : WpfTable
{
public UIListViewPropertiesTable1(UITestControl searchLimitContainer) :
base(searchLimitContainer)
{
#region Search Criteria
this.SearchProperties[WpfTable.PropertyNames.AutomationId] = "listViewProperties";
this.WindowTitles.Add("Properties of Pipe 1");
#endregion
}
#region Properties
public WpfText NameOfComponent
{
get
{
if ((this.mNameOfComponent == null))
{
this.mNameOfComponent = new WpfText(this);
#region Search Criteria
this.mNameOfComponent.SearchProperties[WpfText.PropertyNames.Name] = "Pipe 1";
this.mNameOfComponent.WindowTitles.Add("Properties of Pipe 1");
#endregion
}
return this.mNameOfComponent;
}
}
#endregion
#region Fields
private WpfText mNameOfComponent; …Run Code Online (Sandbox Code Playgroud)