我使用VS2008目标.NET 2.0框架,以防万一,不,我不能改变这个:)
我DateCalculator上课了.其方法GetNextExpirationDate尝试在内部使用DateTime.Today作为基线日期来确定下一个到期时间.
在我编写单元测试时,我意识到我想测试GetNextExpirationDate不同的"今天"日期.
最好的方法是什么?以下是我考虑过的一些替代方案:
baselineDate仅在单元测试中使用它.在实际的客户端代码,忽略了赞成票默认方法的属性/重载方法baselineDate来DateTime.Today.我不愿意这样做,因为它使得DateCalculator类的公共接口变得笨拙.baselineDate内部设置为的受保护字段DateTime.Today.测试时,DateCalculatorForTesting从构造函数派生DateCalculator并设置baslineDate.它使公共接口保持干净,但仍然不是很好 - baselineDate受到保护并且需要派生类,这两者都仅用于测试.ExtensionAttribute,然后意识到它不起作用,因为扩展方法无法访问私有/受保护的变量.我最初认为这是一个非常优雅的解决方案.:(我有兴趣听听别人的想法.
在我们的原始设计中,我们搞砸了表中的外键约束.现在表中充满了数据,我们无法在不删除表中的所有记录的情况下更改它.我能想到的唯一解决方案是创建一个备份表并将所有记录放在那里,然后删除所有记录,更改表并开始添加它们.还有其他(更好)的想法吗?谢谢!
使用MS SQL Server
我做了一个tableView,我需要选择多个选项.选项被选中,但是当我滚动表格视图时,复选标记选项消失,其他一些行显示该复选标记.这是我在代码didselectedrowAtindex的方法table_option是UITableView和selectedcells是NSMutableArray
[table_option deselectRowAtIndexPath:indexPath animated:YES];
NSNumber *rowNsNum = [NSNumber numberWithUnsignedInt:indexPath.row];
if ( [selectedCells containsObject:rowNsNum] )
{
if (cell.accessoryType == UITableViewCellAccessoryCheckmark)
cell.accessoryType = UITableViewCellAccessoryNone;
else
cell.accessoryType = UITableViewCellAccessoryCheckmark;
[selectedCells removeObject:rowNsNum];
sel.text=@"Select";
// cell.accessoryType = UITableViewCellAccessoryNone;
}
else
{
if (cell.accessoryType == UITableViewCellAccessoryCheckmark)
cell.accessoryType = UITableViewCellAccessoryNone;
else
cell.accessoryType = UITableViewCellAccessoryCheckmark;
[selectedCells addObject:rowNsNum];
sel.text=@"Selected";
// cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
[table_option reloadData];
Run Code Online (Sandbox Code Playgroud)
请尽快帮忙
我想在我的项目中添加第三方库Speech-To-TextXcode.我只是xcodeproj在我的iPhone项目中拖动文件.然后我按照Target Dependencies,Link Binary和库之类的步骤进行操作,并设置Header Search路径.但是我对如何正确设置Header搜索路径感到困惑.然后我导入#import SpeechToTextModule.h'那个时候我得到错误就像SpeechToTextModule.h 找不到文件.请帮助我.
提前致谢!!!
我知道删除多个表的语法是:
DROP TABLE foo, bar, baz;
Run Code Online (Sandbox Code Playgroud)
但在我的情况下,3个表之间有外键和其他表不被删除.
那么如何删除这3张桌子呢?他们在表格中有数据.上面的语法会忽略外键吗?数据库中的其他表不应存在任何数据不一致.
我有方法,我想测试:
- (void)sendMailToContact:(Contact *)conact
{
self.contact = conact;
if ([self isSendingAvaiable]) {
MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
mailViewController.mailComposeDelegate = self;
[mailViewController setToRecipients:@[self.contact.email]];
[self.parentViewController presentViewController:mailViewController animated:YES completion:nil];
}
}
Run Code Online (Sandbox Code Playgroud)
考试...
- (void)testSendMailToContact_itShouldShowMFMailComposeViewController
{
UIViewController *mockViewController = [[UIViewController alloc] init];
[mockViewController viewDidLoad];
MailComposer *mockMailComposer = [MailComposer sharedComposerWithController:mockViewController];
[mockMailComposer sendMailToContact:[self mockContact]];
XCTAssertTrue([mockViewController.presentedViewController isKindOfClass:[MFMailComposeViewController class]], @"");
}
Run Code Online (Sandbox Code Playgroud)
但它无法正常工作.我应该将MFMailComposeViewController作为presentViewController,但我有null.我不知道该怎么办.请帮忙!
什么是确定列及其名称是否存在默认约束的方法,以及任何索引的名称,以便在删除列之前删除它们?
我已经整天搜索了Google,但我无法找到解决方案.
我正在尝试在我的iOS应用程序中使用自定义单元格实现表格视图.我正在使用显示不同图像和标签的自定义单元格.一切都工作正常,除了单元格对于表格视图来说太大了.我知道我需要实现heightForRowAtIndexPath方法,但从不调用它.
我已经尝试在nib文件和代码中的ShowPostsViewController中设置TableView的委托,但没有任何帮助.我希望问题可能是dataSource已设置但不是委托.我无法理解为什么.
到目前为止我发现的每个解决方案都说代理设置不正确.但是,我很确定这是我的情况?!我很感激任何帮助.这是我的代码:
ShowPostsViewController.h
@interface ShowPostsViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) IBOutlet UITableView *postsTableView;
@end
Run Code Online (Sandbox Code Playgroud)
和ShowPostsViewController.m
@implementation ShowPostsViewController
@synthesize postsTableView;
- (void)viewDidLoad
{
[super viewDidLoad];
self.postsTableView.delegate = self;
self.postsTableView.dataSource = self;
NSLog(@"Delegate set");
[postsTableView beginUpdates];
NSMutableArray *tempArray = [[NSMutableArray alloc] init];
for(int i=0; i<8; i++){
[tempArray addObject: [NSIndexPath indexPathForRow:i inSection:0]];
}
[postsTableView insertRowsAtIndexPaths:tempArray withRowAnimation:UITableViewRowAnimationAutomatic];
NSLog(@"Updates Called");
[postsTableView endUpdates];
[postsTableView reloadData];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 8;
}
//PostTableViewCell is my custom Cell that I want to display …Run Code Online (Sandbox Code Playgroud) 我在iOS 7中显示分组样式tableView的单元格分隔符时遇到问题.
if ([projectTable respondsToSelector:@selector(setSeparatorInset:)]) {
[projectTable setSeparatorInset:UIEdgeInsetsZero];
projectTable.separatorColor = [UIColor blackColor];
}
Run Code Online (Sandbox Code Playgroud)
这不显示细胞分离器.请建议
我正在研究我在Objective C上完成的一个应用程序.我需要为它添加一个新模块,我决定将Swift用于该特定模块.
我有一个HomePage在Objective C中调用的类,我想在其中添加一些新的IBActions和IBOutlets.为此,我添加了一个新的swift文件并扩展了现有的类,如:
// MARK: IBOutlets and IBActions
extension HomePage
{
@IBOutlet var image : UIImageView!
...
/*!
* Loads the application support webpage
*/
@IBAction func loadSupportURL(sender : UIButton)
{
}
...
}
Run Code Online (Sandbox Code Playgroud)
如果我只添加IBActions,一切都很完美.但是当我添加一个IBOutlet时,编译器会抛出一个错误:
扩展名可能不包含存储的属性
为了解决这个问题,我有两种方法,
有没有其他方法可以解决这个问题?
ios ×6
objective-c ×3
sql-drop ×3
uitableview ×3
iphone ×2
sql ×2
sql-server ×2
c# ×1
constraints ×1
datetime ×1
foreign-keys ×1
iboutlet ×1
indexing ×1
ios7 ×1
postgresql ×1
swift ×1
unit-testing ×1
xcode ×1
xcode4.2 ×1
xctest ×1