473,554 Members | 2,530 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

6 New Member
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.

Oct 7 '09 #1
2 3991
648 Recognized Expert Contributor
Why not just multiply the number returned by 5?

I am not at my pc now, but I think there is a stringwithforma t: that accepts an int.
Oct 7 '09 #2
6 New Member
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.

Oct 7 '09 #3

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

Similar topics

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 SmallTalk really faster than Python? I tried Objective-C, but eventually dropped it for lack of support and the need to use NS-type classes to do...
by: edo | last post by:
JS program to score any objective test http://www.psychology.org/cgi-bin/links2/jump.cgi?ID=3913
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. Thanks P.S. I guess I would like to see a test app given to three programmers with 1-2 years in their specific environment and see the time taken...
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 panel. The central panel is intended to display the main content of the cv: when an anchor is selected from the header then the detail is supposed...
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 SetWindowText(ByVal hWnd As IntPtr, ByVal lpString As String) As Boolean End Function
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 set it up: I have a class module "objPerson" which has a property "FirstName". This works: objPerson.FirstName = "John Smith" strFirstName =...
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 the .cpp files. After some reading, I found that the only way to do this is to add the actual template instantiations in the .cpp file. But, how do...
by: Arjen | last post by:
Hi, Form a performance perspective, is it wise to use the ref statement as much as possible? Thanks! Arjen
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 through our website with experienced teachers available world wide. Some among you can also be teachers while others will be your students. This is fun...
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 c++ i own both a new mac and a windows vista pc. iv'e been doin all my c stuff on xcode on my mac so the obvious path seems to be objective - c but i...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.