是的标题说:-)他们用简单的英语语言是什么意思?我真的不明白Apple网站上的解释,我需要重命名我的目标,我担心之后没有任何作用..
我在大多数视图控制器中注册了三个观察者.有些人有更多,有些人更少,但我想在父类中包含部分注册和注销过程.即使没有观察者,调用取消注册有什么问题吗?是否要求所有三位观察员取消注册?
- (void)registerForKeyboardNotifications
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWasShown:)
name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillBeHidden:)
name:UIKeyboardWillHideNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationWillEnterBackground:)
name:UIApplicationWillResignActiveNotification
object:nil];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
//Has to be unregistered always, otherwise nav controllers down the line will call this method
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
Run Code Online (Sandbox Code Playgroud) 我刚刚在iOS8上遇到过这个新的API.但是,如果可以使用图像而不是文本并允许左右滑动,我无法找到任何解决方案?这甚至可能吗?我发现的唯一实现是:
- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewRowAction *moreAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"Button1" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
// maybe show an action sheet with more options
[self.tableView setEditing:NO];
}];
moreAction.backgroundColor = [UIColor blueColor];
UITableViewRowAction *moreAction2 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"Button2" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
[self.tableView setEditing:NO];
}];
moreAction2.backgroundColor = [UIColor blueColor];
UITableViewRowAction *deleteAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"Delete" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
[self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
}];
return @[deleteAction, moreAction, moreAction2];
}
Run Code Online (Sandbox Code Playgroud) 我想为我的应用程序的用户提供创建核心数据库备份的可能性,特别是在他切换到新设备等的情况下.
我该怎么办?特别是如何重新导入该文件?我的意思是让我们说他制作数据库的备份副本,然后改变了大量的东西,并希望重置为以前保存的备份副本.我该怎么办?
谢谢!
我对R很新,并试图回溯我在WealthLab中编写的策略.
几个我不明白的东西(它显然不起作用:)
我没有很好地将关闭价格转换为向量...或某种向量,但它从结构开始,我真的不明白这个函数的作用.这就是为什么我的系列[,1]调用可能不起作用.
n < - nrow(系列)也不起作用,但我需要循环
所以我想如果我得到这两个问题的答案我的策略应该有效......我非常感谢任何帮助......即使有其他语言的编程经验,看起来也很复杂
#rm(list = ls(all = TRUE))
#import data, default is yahoo
require(quantmod)
series <- getSymbols('AAPL',from='2013-01-01')
#generate HLOC series
close <- Cl(AAPL)
open <- Op(AAPL)
low <-Lo(AAPL)
high <- Hi(AAPL)
#setting parameters
lookback <- 24 #24 days ago
startMoney <- 10000
#Empty our time series for position and returns
f <- function(x) 0 * x
position <- apply(series[,1],FUN=f)
colnames(position)="long_short"
returns <- apply(series[,1],FUN=f)
colnames(returns)="Returns"
trades = returns
colnames(trades)="Trades"
amount = returns
colnames(amount) = "DollarAmount"
amt[seq(1,lookback)] …
Run Code Online (Sandbox Code Playgroud) 好吧问题就是这一切..如果给定的函数参数是xts或数据框类型,我想检查我的一个函数.我怎样才能做到这一点?
我想针对货币对绘制交易策略.当然,交易策略有很大的价值(> 10'000,因为10'000是初始资本),货币对徘徊在1.5左右.因此,我希望将策略覆盖在与货币对相同的图表上,但我需要两个不同的Y尺度.
我怎样才能做到这一点?
像这样两者都在同一个图表中,但是策略(投资)是不可见的,因为它高于货币对的最高点.
和奖金问题:-)
如何将特定日期的数据分组到今天?像2008年到现在还是什么?
FXTimeSeries <- zoo(MergedSet$FXCloseRate,MergedSet$Date)
InvestmentTimeSeries <- zoo(matrix[,"Investment"], MergedSet$Date)
chartSeries(FXTimeSeries, theme="white", subset='2011-04::2013-06')
addTA(InvestmentTimeSeries,legend="Strategy", on=1)
Run Code Online (Sandbox Code Playgroud) 对不起,这个问题听起来有点令人困惑.我有两个按钮在底部重叠我的表视图,因此,如果表视图滚动"正常"的最后一行是部分通过这些按钮隐藏.这就是为什么我要允许滚动像一个行的高度表进一步下跌,所以最后一行是在这两个按钮的上方.我怎样才能做到这一点?
我仍在使用 Guy Yollins quantstrat 示例。在此示例中,当 SPY 穿越 10 日均线时,他买入 1000 股。由于我们定义了初始股本,是否可以始终购买整个投资组合金额而不仅仅是 900 股?“all”不适用于进入,仅适用于退出..
if (!exists('.blotter')) .blotter <- new.env()
if (!exists('.strategy')) .strategy <- new.env()
if (!exists('.instrument')) .instrument <- new.env()
currency("USD")
stock("SPY",currency="USD",multiplier=1)
ls(envir=FinancialInstrument:::.instrument)
initDate <- '1997-12-31'
startDate <- '1998-01-01'
endDate <- '2013-07-31'
initEq <- 1e6
Sys.setenv(TZ="UTC")
getSymbols('SPY', from=startDate, to=endDate, adjust=T)
SPY=to.monthly(SPY, indexAt='endof')
SPY$SMA10m <- SMA(Cl(SPY), 10)
# inz portfolio, account
qs.strategy <- "qsFaber"
rm.strat(qs.strategy) # remove strategy etc. if this is a re-run
initPortf(qs.strategy,'SPY', initDate=initDate)
initAcct(qs.strategy,portfolios=qs.strategy, initDate=initDate, initEq=initEq)
initOrders(portfolio=qs.strategy,initDate=initDate)
# instantiate a …
Run Code Online (Sandbox Code Playgroud) 我已经完成了斯坦福大学的课程,并按照讲座中的步骤设置了我的第一个应用程序和核心数据。大约是这样(我现在将代码转移到应用程序委托中):
- (void)setupFetchedResultsController
{
NSError *error = nil;
NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"MainCategory"];
request.sortDescriptors = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"position" ascending:YES]];
[self.budgetDatabase.managedObjectContext executeFetchRequest:request error:&error];
self.fetchedResultsController = [[NSFetchedResultsController alloc]initWithFetchRequest:request
managedObjectContext:self.budgetDatabase.managedObjectContext
sectionNameKeyPath:nil
cacheName:nil];
}
-(void)useDocument
{
if(![[NSFileManager defaultManager]fileExistsAtPath:[self.budgetDatabase.fileURL path]]){
[self.budgetDatabase saveToURL:self.budgetDatabase.fileURL forSaveOperation:UIDocumentSaveForCreating completionHandler:^(BOOL success) {
[self setupFetchedResultsController];
}];
} else if (self.budgetDatabase.documentState == UIDocumentStateClosed){
[self.budgetDatabase openWithCompletionHandler:^(BOOL success){
[self setupFetchedResultsController];
}];
} else if (self.budgetDatabase.documentState == UIDocumentStateNormal){
[self setupFetchedResultsController];
}
}
- (void)viewWillAppear:(BOOL)animated
{
//Initialize database
[super viewWillAppear:animated];
if(!self.budgetDatabase){
NSURL *url = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentationDirectory …
Run Code Online (Sandbox Code Playgroud) ios ×6
r ×4
objective-c ×3
core-data ×2
quantmod ×2
uitableview ×2
backup ×1
charts ×1
dataframe ×1
quantstrat ×1
types ×1
uiscrollview ×1
xcode ×1
xts ×1