UIslider increase 10 by 10 - iphone

I'm making an UISlider and I don't find how to change the selectable values, I would like the only values possible be 10 by 10.
The slider begins at 82 and ends at 362. I want the possible value to be 82,92,102,.....
I've tried different things but I don't find
[sliderannonce setValue: [sliderannonce value]+10.0 animated:YES];
or
sliderannonce.value=10;
I've my action here:
- (IBAction)changeSliderAnnonce:(id)sender{
labelSliderAnnonce.text = [[NSString alloc] initWithFormat:#"annonce:%d",(int)sliderannonce.value];
}
If you did something like that or you know how to do please let me know.

Wouldn't it be simpler to just multiply the value by 10 in your code and add the starting value?
Example : start the slider at 0, end at 28 :
int position = 82 + ((int)sliderannonce.value) * 10;

Finally found a way to "cheat" with your idea thanks :D
I started to 8,2 and end to 36,2 and I multiply by 10
- (IBAction)changeSliderAnnonce:(id)sender{
int position= ((int)sliderannonce.value)*10+2;
labelSliderAnnonce.text = [[NSString alloc] initWithFormat:#"annonce: %d",((int)sliderannonce.value)*10+ 2];
NSLog(#"valeur de l'enchere: %d",position);
}

Related

QlikSense - Set Analysis - Handling complexities - Arithmetic, Fields, Variables, Variables within variables, Greater than etc

I am somewhat new to QlikSense, but am getting a hang of it. Set Analysis is probably my weak spot and no matter how much I read, I tend to forget everything within hours. Plus, the guides don't do a great job explaining how to handle more complex/'tricky' situations (aka Level II or III complexity) than what they deem complex (aka Level 1 complexity) .
I went through this, this and this, still no dice. The only thing left for me to do is to bang my head to the wall and see if something shakes up.
The actual file is pretty big and proprietary, so can't post it here... so I would appreciate if you can give me an idea and point me in the right direction.
GOAL:
I have an expression that works, but I need it in the form of set analysis. Simple, right?
BACKGROUND:
//IN LOAD SCRIPT - set some default values
SET dMinSOS = 20000;
SET dMaxSUSPD = 225;
SET dSUR = 1;
SET dSOR = 0.3;
//IN LOAD SCRIPT - generate some custom inputs so user can select a value
FOR i = 1 to 20
LET counter = i*5000;
LOAD * INLINE [
Min. SOS
$(counter)
];
NEXT i
FOR i = 0 to 9
LET counter = i/10;
LOAD * INLINE [
SOR
$(counter)
];
NEXT i
FOR i = 1 to 30
LET counter = i/10;
LOAD * INLINE [
SUR
$(counter)
];
NEXT i
FOR i = 1 to 15
LET counter = i*25;
LOAD * INLINE [
Max. SUSPD
$(counter)
];
NEXT i
//IN LOAD SCRIPT - if user selects a value from above, then get the max because they can select multiple; otherwise use default values
SET vMinSOS = "IF(ISNULL([Min. SOS]), $(dMinSOS), MAX([Min. SOS]))";
SET vMaxSUSPD = "IF(ISNULL([Max. SUSPD]), $(dMaxSUSPD), MAX([Max. SUSPD]))";
SET vSUR = "IF(ISNULL([SUR]), $(dSUR), MAX([SUR]))";
SET vSOR = "IF(ISNULL([SOR]), $(dSOR), MAX([SOR]))";
//EXPRESSION - works! - [Size], [Heads], [SPD] are direct fields in a table, the return value of 1 or 0 is strictly for reference
=IF(
[Size] >= $(vMinSOS) AND
[Size] - ((([Heads] * IF([SPD] >= $(vMaxSUSPD), $(vMaxSUSPD), [SPD])) / $(vSUR)) + ([Size] * $(vSOR))) >= 0,
1, 0)
//SET ANALYSIS - this needs fixing - i.e. replicate 2nd condition in expression above - Show just the results where both the conditions above are true
=SUM({<
[Size]={">=$(=$(vMinSOS))"},
[Size]={">= #### What goes here? #### "},
>}[Size])
Open to recommendations on better ways of solving this.
=SUM({
"=[Size] >= $(vMinSOS) AND [Size] - ((([Heads] * IF([SPD] >= $(vMaxSUSPD), $(vMaxSUSPD), [SPD])) / $(vSUR)) + ([Size] * $(vSOR))) >= 0"
}>} [Size] )

How to debug missing dataset

I am working on a graph implementation for a health app and the user can choose which fields to graph.
There are some combination of fields which never appear on the graph.
From the debugging I have done so far I can see that the values for all the fields are created correctly.
So ultimately my question is, why is there no line for "Weight Moving Average"
But really I would like to know how to debug this problem. What be the recommended next step for getting to the bottom of it?
Code:
if (isMovingAverage) {
dataset.mode = LineChartModeCubicBezier;
dataset.cubicIntensity = 0.1;
dataset.lineWidth = 2;
dataset.highlightEnabled = NO;
[dataset setColor: baseColor];
dataset.fillAlpha = 1.f;
dataset.drawCirclesEnabled = NO;
NSArray *gradientColors = #[
(id)[UIColor whiteColor].CGColor,
(id)baseColor.CGColor
];
CGGradientRef gradient = CGGradientCreateWithColors(nil, (CFArrayRef)gradientColors, nil);
dataset.fillAlpha = 1.f;
dataset.fill = [ChartFill fillWithLinearGradient:gradient angle:90.f];
dataset.drawFilledEnabled = YES;
dataset.drawHorizontalHighlightIndicatorEnabled = NO;
CGGradientRelease(gradient);
NSLog(#"Dataset: %#", dataset);
}
Debug output:
Formatting: Weight Moving Avg
2017-07-28 17:06:49.425518+0100 BodyTrackItLite[5239:1893083] Using color: UIExtendedSRGBColorSpace 0.07 0.62 0.64 1
2017-07-28 17:06:49.426723+0100 BodyTrackItLite[5239:1893083] Dataset: Charts.LineChartDataSet, label: Weight Moving Average, 140 entries
Metaphox was right in his comment, one dataset was blocking the others and so the solution was to remove the gradient fill.
I don't have a good answer as how best to approach debugging the charts component though.

Difference between two date time stamp in Intersystems Cache

I would like to find out the number of hours and minutes between two date time stamp.
if for example
sDateTime = 2016-01-01 01:00
eDateTime = 2016-01-03 02:30
I would like it to output it as 49:30 (49hours and 30minutes)
I am unable to figure a method to work this out.
what I have so far:
Set oMNOF=##class(MNOF.MNOF).%OpenId(Id)
Set zstartDt=oMNOF.sDateTime
Set startDt=$PIECE(zstartDt,",",1)
Set startTime=$PIECE(zstartDt,",",2)
Set zendDt=oMNOF.eDateTime
Set endDt=$PIECE(zendDt,",",1)
Set endTime=$PIECE(zendDt,",",2)
set dateDiff=((endDt - startDt)) //2 days
set timeDiff=(endTime - startTime) //outputs 5400 seconds
set d = (dateDiff * 24 * 60 * 60)
set h = ((timeDiff - d) / 60)
set m = timeDiff - (d) - (h * 60)
Thank you for the help.
Another option:
USER>set mm=$system.SQL.DATEDIFF("mi","2016-01-02 01:00","2016-01-03 02:30")
USER>write "hours=", mm \ 60
hours=25
USER>write "minutes=", mm # 60
minutes=30
Hi thanks to all for the help.
I managed to come up with the below, appreciate if someone can improve on this.
<script language="cache" method="MGetData" arguments="pStartDt:%String,pEndDt:%String,pTimeField:%String" returntype="%Library.String">
set val1="00"
//HOUR: check if length equals 1
if $LENGTH($SYSTEM.SQL.FLOOR($system.SQL.DATEDIFF("ss",pStartDt,pEndDt)/3600))=1{
//add leading zero
set val1 ="0"_$SYSTEM.SQL.FLOOR($system.SQL.DATEDIFF("ss",pStartDt,pEndDt)/3600)
}
else{
//get without leading zero
set val1 = $SYSTEM.SQL.FLOOR($system.SQL.DATEDIFF("ss",pStartDt,pEndDt)/3600)
}
//MINUTES: check if length equals 1
if $LENGTH($SYSTEM.SQL.FLOOR($system.SQL.DATEDIFF("ss",pStartDt,pEndDt)/60) - ($SYSTEM.SQL.FLOOR($system.SQL.DATEDIFF("ss",pStartDt,pEndDt)/3600)*60))=1{
//add leading zero
set val2 ="0"_($SYSTEM.SQL.FLOOR($system.SQL.DATEDIFF("ss",pStartDt,pEndDt)/60) - ($SYSTEM.SQL.FLOOR($system.SQL.DATEDIFF("ss",pStartDt,pEndDt)/3600)*60))
}
else{
//get without leading zero
set val2 = ($SYSTEM.SQL.FLOOR($system.SQL.DATEDIFF("ss",pStartDt,pEndDt)/60) - ($SYSTEM.SQL.FLOOR($system.SQL.DATEDIFF("ss",pStartDt,pEndDt)/3600)*60))
}
//insert result data into the time field
Write "document.getElementById('"_pTimeField_"').value='"_val1_":"_val2_"';"
//Write "alert('"_val1_"^"_val2_"');"
QUIT 1

Objective C : Get correct float values(justified)

I worked a lot in it and can't find a solution. Even the title can't explain clearly.
I have three values weight, quantity and total
I had done the following
float wq = [[weightarray objectAtIndex:selectedint]floatValue];
float q = [quantity floatValue];
float total = wq * q;
for ex, if
[weightarray objectAtIndex:selectedint] = #"3.14";
quantity = 4;
then the result is
wq = 3.140000 q= 4.000000 total = 12.560000
but I need
wq = 3.14 total = 12.56
what to do?
I searched a lot, someone suggests to use NSDecimal,
NSDecimalNumberHandler *roundingBehavior = [NSDecimalNumberHandler decimalNumberHandlerWithRoundingMode:NSRoundPlain scale:2 raiseOnExactness:FALSE raiseOnOverflow:TRUE raiseOnUnderflow:TRUE raiseOnDivideByZero:TRUE];
but the scale is not 2 here, wq value may have 3 or four numbers after point.
If the total = 2.30000100 means I need total = 2.300001
how to solve this?
I'm not entirely sure what it is your asking for, but it seems as if you want the values to only display a 2 d.p. In which case you could use a string format like so:
NSString *output = [NSString stringWithFormat:#"float = %.2f", 3.14];
The .2 specifies that the float should be justified to 2 d.p.
Hope this helps
There may be a more direct way to achieve it (which I don't know) but here's a suggestion...
Convert to string as you already do.
Use [myString hasSuffix:#"0"] to see if it ends in zero.
Use [myString substringToindex:[myString length]-1] to create a new string without the final zero.
Repeat.
I know it's not elegant, but unless someone has a better solution, this will at least do what you want.
UPDATE: scratch that - I just discovered [myString stringByTrimmingCharactersInSet:set]. Surely this must be what you need...?
Finally solution found, thanks to Martin
float total = 12.56000;
NSString *s = [NSString stringWithFormat:#"%f", total];
NSLog(#"%#",s);
BOOL success;
success =NO;
while(!success)
{
if ([s hasSuffix:#"0"])
{
s = [s substringWithRange:NSMakeRange(0,[s length]-1)];
}
else if ([s hasSuffix:#"."])
{
s = [s substringWithRange:NSMakeRange(0,[s length]-1)];
success = YES;
}
else
success = YES;
}
NSLog(#"%#",s);
if total = 12.560000 it returns total = 12.56
if total = 12.000000 it returns total = 12
if total = 10.000000 it returns total = 10
if total = 12.3000100 it returns total = 12.30001

Format a float value to get the digits before a decimal point

In my application I have a music player, which plays music with a length of 0:30 seconds.
However in a UILabel I am currently displaying the progress, and as it is a float, the label is displaying i.e 14.765.
I would appreciate it if you could tell me how I could get the label to display
0:14 rather than 14.765.
Also, I would appreciate it if you could tell me how I could display 0:04 if the progress was 4seconds in.
This works properly:
float time = 14.765;
int mins = time/60;
int secs = time-(mins*60);
NSString * display = [NSString stringWithFormat:#"%d:%02d",mins,secs];
Results:
14.765 => 0:14
30.000 => 0:30
59.765 => 0:59
105.999 => 1:45
EDIT
In addition the 'one liner':
float time = 14.765;
NSString * display = [NSString stringWithFormat:#"%d:%02d",(int)time/60,(int)time%60];
You first need to convert your float to an integer, rounding as you wish. You can then use the integer division, /, and remainder, % operations to extract minutes and seconds and produce a string:
float elapsedTime = 14.765;
int wholeSeconds = round(elapsedTime); // or ceil (round up) or floor (round down/truncate)
NSString *time = [NSString stringWithFormat:#"%02d:%02d", wholeSeconds/60, wholeSeconds%60];
The %02d is the format specification for a 2-digits, zero padded, integer - look up printf in the docs for full details.
//%60 remove the minutes and int removes the floatingpoints
int seconds = (int)(14.765)%60;
// calc minutes
int minutes = (int)(14.765/60);
// validate if seconds have 2 digits
NSString time = [NSString stringWithFormat:#"%i:%02i",minutes,seconds];
that should work. Can't test it i'm on Win currently