Система. Таймеры. Таймер . Если Вы захотите работать в определенные времена дня, необходимо будет выяснить, какой длины это до следующего раза и установило это как интервал.
Это - просто основная идея. В зависимости от того, насколько точный необходимо быть Вами, может сделать больше.
int minutes = DateTime.Now.Minute;
int adjust = 10 - (minutes % 10);
timer.Interval = adjust * 60 * 1000;
У меня нет под рукой подходящего компилятора Objective-C, но пока конструкции C идентичны:
switch {…}
дает вам один область на уровне блока, а не по одной для каждого случая
. Объявление переменной в любом месте, кроме начала области действия является недопустимым, и внутри переключателя
особенно опасно, потому что его инициализация может быть перепрыгнута.
Выполните одно из следующих действий. проблема?
NSString *viewDataKey;
switch (cellNumber) {
case 1:
viewDataKey = @"Name";
…
}
switch (cellNumber) {
case 1: {
NSString *viewDataKey = @"Name";
…
}
…
}
You can't declare a variable at the beginning of a case statement. Make a test case that just consists of that and you'll get the same error.
It doesn't have to do with variables being declared in the middle of a block — even adopting a standard that allows that won't make GCC accept a declaration at the beginning of a case statement. It appears that GCC views the case label as part of the line and thus won't allow a declaration there.
A simple workaround is just to put a semicolon at the beginning of the case so the declaration is not at the start.
In C you only can declare variables at the begining of a block before any non-declare statements.
{
/* you can declare variables here */
/* block statements */
/* You can't declare variables here */
}
In C++ you can declare variables any where you need them.
Может быть, объявление переменной в блоке переключателя недопустимо?