473,405 Members | 2,445 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Using an Objective-C array with a slider to return custom values generates warning

I do not want my iPhone slider to return simple numbers like 1, 2, 3, etc. to the text label, but 15mm, 15.5mm, 16mm, etc., from 15mm to 45mm in increments of .5. So I thought I would put all the acceptable numbers in an array and link the slider output with the corresponding object in the array. (Slider returning "0" will link to the first element of the array, etc.)

Here is how I've tried to link the output to the array, and the warning it generated (line 5, for line 4):

Expand|Select|Wrap|Line Numbers
  1. -(void)sliderAction:(id)sender{
  2. NSArray *array = [NSArray arrayWithObjects: @"15", @"15.5", ..., @"45", nil];
  3. NSString *labelValue; // This var will pass the value to the text label
  4. labelValue = [array objectAtIndex:slider.value]; // Slider will pass a number from 0-59
  5. // warning: passing argument 1 of 'objectAtIndex' makes integer from pointer without a cast
  6. label.text = [NSString stringWithFormat:@"%02.0fmm", labelValue]; // The array number and "mm" will be sent to the text label
  7. [labelValue release]; // release the memory
  8. }
How do I change the type from a number to a string (I think that's what will take away the warning)? I've been coding in Obj-C for the last three months, and came from a PHP background.

Thanks!
Steve
Oct 7 '09 #1
2 3987
markmcgookin
648 Expert 512MB
Why not just multiply the number returned by 5?

I am not at my pc now, but I think there is a stringwithformat: that accepts an int.
Oct 7 '09 #2
I will use several sliders in the app, and not all the sliders will return numbers as consistently spaced as these. Another array will have numbers that seem to be at random. That's why I'm using an array. If I get this one right, I'll get them all right.

I don't see how multiplying an integer by 5 can get me 15.5.

Thanks!
Steve
Oct 7 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: j_mckitrick | last post by:
Hi all! I've heard good things about SmallTalk, and I read that the IDE is extremely productive. Why is this the case? What are the technical points where Python and SmallTalk differ? Is...
1
by: edo | last post by:
JS program to score any objective test http://www.psychology.org/cgi-bin/links2/jump.cgi?ID=3913
2
by: David | last post by:
Anyone know of objective a survey of the development time and run-time considerations of PHP vs. ASP.NET vs JSP? Most arguments for one environment appear to be more on the personal level. ...
3
by: bloc | last post by:
I am programming an interactive CV using xml, xslt and java script. The page consists of a header which contains links to various 'sections' on the xml cv, a left and right menu, and a central...
7
by: support | last post by:
Hi, I am trying to change the text of a Command button using the Windows API Function SetWindowText, which I have declared as follows: <DllImport("User32")_ Public Function...
13
by: Genki | last post by:
Can you figure out how to do this in Access2002/VBA? I want to get the value of an object property. The trick is that the name of the property to retrieve is stored in a table. Here's how I've...
14
by: aaragon | last post by:
Hi everyone, I've been writing some code and so far I have all the code written in the .h files in order to avoid the linker errors. I'm using templates. I wanted to move the implementations to...
65
by: Arjen | last post by:
Hi, Form a performance perspective, is it wise to use the ref statement as much as possible? Thanks! Arjen
0
by: babu8880 | last post by:
www.convensysglobal.com/elearn You can login and attend courses and similar resources ask your doubts from experienced engineers in iphone and Objective C Domain You can attend live classes...
4
by: wayneface | last post by:
hey guys im quite new to programming and have been teaching myself c, ive come to the point where object orientated languages are calling to me but i can't decide weather to go onto objective - c or...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.